about summary refs log tree commit diff
path: root/pkgs/build-support/testers/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support/testers/default.nix')
-rw-r--r--pkgs/build-support/testers/default.nix29
1 files changed, 28 insertions, 1 deletions
diff --git a/pkgs/build-support/testers/default.nix b/pkgs/build-support/testers/default.nix
index d983e43c0bf19..3ab97760e725d 100644
--- a/pkgs/build-support/testers/default.nix
+++ b/pkgs/build-support/testers/default.nix
@@ -1,4 +1,4 @@
-{ pkgs, lib, callPackage, runCommand }:
+{ pkgs, lib, callPackage, runCommand, stdenv }:
 # Documentation is in doc/builders/testers.chapter.md
 {
   testEqualDerivation = callPackage ./test-equal-derivation.nix { };
@@ -33,4 +33,31 @@
         else salted;
     in checked;
 
+  # See doc/builders/testers.chapter.md or
+  # https://nixos.org/manual/nixpkgs/unstable/#tester-invalidateFetcherByDrvHash
+  nixosTest =
+    let
+      /* The nixos/lib/testing-python.nix module, preapplied with arguments that
+       * make sense for this evaluation of Nixpkgs.
+       */
+      nixosTesting =
+        (import ../../../nixos/lib/testing-python.nix {
+          inherit (stdenv.hostPlatform) system;
+          inherit pkgs;
+          extraConfigurations = [(
+            { lib, ... }: {
+              config.nixpkgs.pkgs = lib.mkDefault pkgs;
+            }
+          )];
+        });
+    in
+      test:
+        let
+          loadedTest = if builtins.typeOf test == "path"
+            then import test
+            else test;
+          calledTest = lib.toFunction loadedTest pkgs;
+        in
+          nixosTesting.makeTest calledTest;
+
 }