From 672368db8343fc43a2b408febca3ac5821ffb607 Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Sat, 4 May 2024 10:48:22 +0800 Subject: [PATCH] nixos/aplaz: use `x86_64-linux` metis for crossing compiling the kernel --- nixos/configurations/aplaz/cross.nix | 28 ++++++++++++++++++++++++++ nixos/configurations/aplaz/default.nix | 1 + nixos/modules/nix.nix | 1 + 3 files changed, 30 insertions(+) create mode 100644 nixos/configurations/aplaz/cross.nix diff --git a/nixos/configurations/aplaz/cross.nix b/nixos/configurations/aplaz/cross.nix new file mode 100644 index 00000000..58335c39 --- /dev/null +++ b/nixos/configurations/aplaz/cross.nix @@ -0,0 +1,28 @@ +# Specify cross-builds on aplaz. +{ pkgs, inputs, lib, config, ... }: +let + pkgsX86Cross = import pkgs.path { + crossSystem.system = "aarch64-linux"; + localSystem.system = "x86_64-linux"; + overlays = [ inputs.nixos-apple-silicon.overlays.apple-silicon-overlay ]; + }; +in +{ + nix.buildMachines = [ + { + hostName = "metis"; + system = "x86_64-linux"; + protocol = "ssh"; + supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; + mandatoryFeatures = [ ]; + } + ]; + + nix.distributedBuilds = true; + + # Use x86_64 linux cross-compiled kernel. + boot.kernelPackages = lib.mkForce (pkgsX86Cross.linux-asahi.override { + _kernelPatches = config.boot.kernelPatches; + withRust = config.hardware.asahi.withRust; + }); +} diff --git a/nixos/configurations/aplaz/default.nix b/nixos/configurations/aplaz/default.nix index 7f47c907..f83decdd 100644 --- a/nixos/configurations/aplaz/default.nix +++ b/nixos/configurations/aplaz/default.nix @@ -10,6 +10,7 @@ in { imports = [ # Include the results of the hardware scan. + ./cross.nix ./hardware-configuration.nix ./wireguard.nix inputs.nixos-apple-silicon.nixosModules.apple-silicon-support diff --git a/nixos/modules/nix.nix b/nixos/modules/nix.nix index d4592be0..49d7c631 100644 --- a/nixos/modules/nix.nix +++ b/nixos/modules/nix.nix @@ -23,6 +23,7 @@ warn-dirty = false; system-features = [ "kvm" "big-parallel" ]; use-xdg-base-directories = true; + builders-use-substitutes = true; }; package = pkgs.nixUnstable; gc = {