runNixOSTest: adds support for lib.extend

When lib overrides were used, before this commit, they would not be made
available in the configuration evaluation of nixosTest's nodes.

Sample code:
``` nix
let
  pkgs = import ./. {
    overlays = [
      (new: old: {
        lib = old.lib.extend (self: super: {
          sorry_dave = builtins.trace "There are no pod bay doors" "sorry dave";
        });
      })
    ];
  };
in
pkgs.testers.runNixOSTest {
  name = "demo lib overlay";

  nodes = {
    machine = { lib, ... }: {
      environment.etc."got-lib-overlay".text = lib.sorry_dave;
    };
  };

  testScript = { nodes }:
    ''
      start_all()
      machine.succeed('grep dave /etc/got-lib-overlay')
    '';
}
```
This commit is contained in:
Arthur Gautier 2023-06-14 23:12:44 -07:00
parent 18c734d7f2
commit 562f879cd1

View File

@ -97,7 +97,9 @@
# See doc/builders/testers.chapter.md or
# https://nixos.org/manual/nixpkgs/unstable/#tester-runNixOSTest
runNixOSTest =
let nixos = import ../../../nixos/lib {};
let nixos = import ../../../nixos/lib {
inherit lib;
};
in testModule:
nixos.runTest {
_file = "pkgs.runNixOSTest implementation";