diff --git a/morph/lib/default.nix b/morph/lib/default.nix index c43fa6ea1ebc6b3159f3f2f6872c23f0da62b776..f236b8cada99b71cd1c5ab851f3c081421c4b717 100644 --- a/morph/lib/default.nix +++ b/morph/lib/default.nix @@ -26,6 +26,13 @@ "megacli" ]; }; - overlays = []; + # Expose `nixos/pkgs` as an attribute of our package set. + # This is is primarly consumed by `nixos/modules/packages.nix`, which + # then exposes it as a module argument. We do this here, so that + # the package set only needs to be evaluted once for the grid, rather + # than once for each host. + overlays = [ + (self: super: { ourpkgs = self.callPackage ../../nixos/pkgs {}; }) + ]; }; } diff --git a/nixos/modules/packages.nix b/nixos/modules/packages.nix index c4390dc00f3948e04e3e90ef270261cc0dd1cdbb..5879e6d63e6e69c2517127dea94cc058ef9ce76a 100644 --- a/nixos/modules/packages.nix +++ b/nixos/modules/packages.nix @@ -1,7 +1,9 @@ # A NixOS module which exposes custom packages to other modules. { pkgs, ...}: let - ourpkgs = pkgs.callPackage ../../nixos/pkgs {}; + # Get our custom packages; either from the nixpkgs attribute added via an + # overlay in `morph/lib/default.nix`, or by importing them directly. + ourpkgs = pkgs.ourpkgs or (pkgs.callPackage ../pkgs {}); in { config = { # Expose `nixos/pkgs` as a new module argument `ourpkgs`. diff --git a/nixos/system-tests.nix b/nixos/system-tests.nix index 218132fe2cd3857f4c201085b4df56a411c794d4..819b5c738eca08b95d3c85b14088a2bf6c000dbf 100644 --- a/nixos/system-tests.nix +++ b/nixos/system-tests.nix @@ -1,7 +1,11 @@ # The overall system test suite for PrivateStorageio NixOS configuration. { pkgs }: -{ - private-storage = pkgs.nixosTest ./tests/private-storage.nix; - spending = pkgs.nixosTest ./tests/spending.nix; - tahoe = pkgs.nixosTest ./tests/tahoe.nix; +let + # Add custom packages as an attribute, so it they only need to be evalutated once. + # See the comment in `morph/lib/default.nix` for details. + pkgs' = pkgs.extend (self: super: { ourpkgs = self.callPackage ./pkgs {}; }); +in { + private-storage = pkgs'.nixosTest ./tests/private-storage.nix; + spending = pkgs'.nixosTest ./tests/spending.nix; + tahoe = pkgs'.nixosTest ./tests/tahoe.nix; }