From 3b5ff938ce3caaa100e827d235a2ad845e72f3f9 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 5 Aug 2023 09:32:50 +0000 Subject: [PATCH] flake: apply nixpatches/list.nix using the build patcher, not the emulated host patcher --- flake.nix | 18 +++++++++++------- hosts/instantiate.nix | 5 ++--- nixpatches/flake.nix | 8 +++++++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/flake.nix b/flake.nix index 7dc0324f..f3a5b4a9 100644 --- a/flake.nix +++ b/flake.nix @@ -94,7 +94,17 @@ evalHost = { name, local, target }: nixpkgs.lib.nixosSystem { system = target; modules = [ - (import ./hosts/instantiate.nix { localSystem = local; hostName = name; }) + { + nixpkgs = (if (local != null) then { + buildPlatform = local; + } else {}) // { + # TODO: does the earlier `system` arg to nixosSystem make its way here? + hostPlatform.system = target; + }; + # nixpkgs.buildPlatform = local; # set by instantiate.nix instead + # nixpkgs.config.replaceStdenv = { pkgs }: pkgs.ccacheStdenv; + } + (import ./hosts/instantiate.nix { hostName = name; }) self.nixosModules.default self.nixosModules.passthru { @@ -103,12 +113,6 @@ self.overlays.sane-all ]; } - ({ lib, ... }: { - # TODO: does the earlier `system` arg to nixosSystem make its way here? - nixpkgs.hostPlatform.system = target; - # nixpkgs.buildPlatform = local; # set by instantiate.nix instead - # nixpkgs.config.replaceStdenv = { pkgs }: pkgs.ccacheStdenv; - }) ]; }; in { diff --git a/hosts/instantiate.nix b/hosts/instantiate.nix index 8f342719..0e475b39 100644 --- a/hosts/instantiate.nix +++ b/hosts/instantiate.nix @@ -1,10 +1,10 @@ # trampoline from flake.nix into the specific host definition, while doing a tiny bit of common setup # args from flake-level `import` -{ hostName, localSystem }: +{ hostName }: # module args -{ lib, ... }: +{ ... }: { imports = [ @@ -14,5 +14,4 @@ ]; networking.hostName = hostName; - nixpkgs.buildPlatform = lib.mkIf (localSystem != null) localSystem; } diff --git a/nixpatches/flake.nix b/nixpatches/flake.nix index 0edc1f64..4aedf29d 100644 --- a/nixpatches/flake.nix +++ b/nixpatches/flake.nix @@ -15,9 +15,15 @@ patchedFlakeFor = system: import "${patchedPkgsFor system}/flake.nix"; patchedFlakeOutputsFor = system: (patchedFlakeFor system).outputs { inherit self; }; + + extractBuildPlatform = nixosSystemArgs: + let + firstMod = builtins.head nixosSystemArgs.modules; + in + firstMod.nixpkgs.buildPlatform or nixosSystemArgs.system; in { - lib.nixosSystem = args: (patchedFlakeOutputsFor args.system).lib.nixosSystem args; + lib.nixosSystem = args: (patchedFlakeOutputsFor (extractBuildPlatform args)).lib.nixosSystem args; legacyPackages = builtins.mapAttrs (system: _: