Commit f659db7b authored by Robert Hensing's avatar Robert Hensing
Browse files

nixos/testing: Add node.pkgs option

By factoring out this logic, it's easier for other projects to make
use of it this optimization too (and do it correctly).
parent d0b0f9e4
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
testModuleArgs@{ config, lib, hostPkgs, nodes, ... }:

let
  inherit (lib) mkOption mkForce optional types mapAttrs mkDefault mdDoc;
  inherit (lib) mkOption mkForce optional types mapAttrs mkDefault mkIf mdDoc;

  baseOS =
    import ../eval-config.nix {
@@ -72,6 +72,19 @@ in
      default = { };
    };

    node.pkgs = mkOption {
      description = mdDoc ''
        The Nixpkgs to use for the nodes.

        Setting this will make the `nixpkgs.*` options read-only, to avoid mistakenly testing with a Nixpkgs configuration that diverges from regular use.
      '';
      type = types.nullOr types.pkgs;
      default = null;
      defaultText = literalMD ''
        `null`, so construct `pkgs` according to the `nixpkgs.*` options as usual.
      '';
    };

    node.specialArgs = mkOption {
      type = types.lazyAttrsOf types.raw;
      default = { };
@@ -104,5 +117,12 @@ in
        config.nodes;

    passthru.nodes = config.nodesCompat;

    defaults = mkIf (config.node.pkgs != null) {
      nixpkgs.pkgs = config.node.pkgs;
      imports = [ ../../modules/misc/nixpkgs/read-only.nix ];
      disabledModules = [{ key = "nodes.nix-pkgs"; }];
    };

  };
}
+1 −5
Original line number Diff line number Diff line
@@ -79,11 +79,7 @@ let
    # warnIf pkgs.config.allowAliases "nixosTests: pkgs includes aliases."
    {
      _class = "nixosTest";
      defaults = {
        nixpkgs.pkgs = pkgs;
        imports = [ ../modules/misc/nixpkgs/read-only.nix ];
        disabledModules = [{ key = "nodes.nix-pkgs"; }];
      };
      node.pkgs = pkgs;
    };

in {