diff --git a/flake.lock b/flake.lock index 3d2fae0c1..e6985aef0 100644 --- a/flake.lock +++ b/flake.lock @@ -82,11 +82,11 @@ }, "nixpkgs-unpatched": { "locked": { - "lastModified": 1683408522, - "narHash": "sha256-9kcPh6Uxo17a3kK3XCHhcWiV1Yu1kYj22RHiymUhMkU=", + "lastModified": 1684049129, + "narHash": "sha256-7WB9LpnPNAS8oI7hMoHeKLNhRX7k3CI9uWBRSfmOCCE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "897876e4c484f1e8f92009fd11b7d988a121a4e7", + "rev": "0470f36b02ef01d4f43c641bbf07020bcab71bf1", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 5b97a2212..454d28b4d 100644 --- a/flake.nix +++ b/flake.nix @@ -92,38 +92,31 @@ nixpkgs = nixpkgs-unpatched; }; - nixpkgsCompiledBy = local: nixpkgs.legacyPackages."${local}"; + nixpkgsCompiledBy = system: nixpkgs.legacyPackages."${system}"; - evalHost = { name, local, target }: - let - # XXX: we'd prefer to use `nixosSystem = (nixpkgsCompiledBy target).nixos` - # but it doesn't propagate config to the underlying pkgs, meaning it doesn't let you use - # non-free packages even after setting nixpkgs.allowUnfree. - # XXX: patch using the target -- not local -- otherwise the target will - # need to emulate the host in order to rebuild! - nixosSystem = import ((nixpkgsCompiledBy target).path + "/nixos/lib/eval-config.nix"); - in - (nixosSystem { - modules = [ - (import ./hosts/instantiate.nix { localSystem = local; hostName = name; }) - self.nixosModules.default - self.nixosModules.passthru - { - nixpkgs.overlays = [ - self.overlays.disable-flakey-tests - self.overlays.passthru - self.overlays.pins - self.overlays.pkgs - # self.overlays.optimizations - ]; - } - ({ lib, ... }: { - nixpkgs.hostPlatform.system = target; - # nixpkgs.buildPlatform = local; # set by instantiate.nix instead - # nixpkgs.config.replaceStdenv = { pkgs }: pkgs.ccacheStdenv; - }) + evalHost = { name, local, target }: nixpkgs.lib.nixosSystem { + system = target; + modules = [ + (import ./hosts/instantiate.nix { localSystem = local; hostName = name; }) + self.nixosModules.default + self.nixosModules.passthru + { + nixpkgs.overlays = [ + self.overlays.disable-flakey-tests + self.overlays.passthru + self.overlays.pins + self.overlays.pkgs + # self.overlays.optimizations ]; - }); + } + ({ 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 { nixosConfigurations = let diff --git a/nixpatches/flake.nix b/nixpatches/flake.nix index eb8c6ad51..d339f9e6f 100644 --- a/nixpatches/flake.nix +++ b/nixpatches/flake.nix @@ -1,5 +1,6 @@ { inputs = { + # user is expected to define this from their flake via `inputs.nixpkgs.follows = ...` nixpkgs = {}; }; outputs = { self, nixpkgs }@inputs: @@ -16,6 +17,8 @@ (patchedFlakeFor system).outputs { inherit self; }; in { + lib.nixosSystem = args: (patchedFlakeOutputsFor args.system).lib.nixosSystem args; + legacyPackages = builtins.mapAttrs (system: _: (patchedFlakeOutputsFor system).legacyPackages."${system}"