summary refs log tree commit diff
path: root/pkgs/build-support/testers/default.nix
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2022-05-05 12:41:34 +0200
committerRobert Hensing <robert@roberthensing.nl>2022-05-05 12:48:47 +0200
commit7edb41466086f8cd19fc738e8f9c46b7c64fe182 (patch)
treee69fed8dd94238eed42dc38a79cd21ceda9c15e0 /pkgs/build-support/testers/default.nix
parent28f99aad3180b8da8db1bd2f8bbe98947de867c3 (diff)
downloadnixpkgs-7edb41466086f8cd19fc738e8f9c46b7c64fe182.tar
nixpkgs-7edb41466086f8cd19fc738e8f9c46b7c64fe182.tar.gz
nixpkgs-7edb41466086f8cd19fc738e8f9c46b7c64fe182.tar.bz2
nixpkgs-7edb41466086f8cd19fc738e8f9c46b7c64fe182.tar.lz
nixpkgs-7edb41466086f8cd19fc738e8f9c46b7c64fe182.tar.xz
nixpkgs-7edb41466086f8cd19fc738e8f9c46b7c64fe182.tar.zst
nixpkgs-7edb41466086f8cd19fc738e8f9c46b7c64fe182.zip
testers.nixosTest: Move from top-level and improve docs
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 d983e43c0bf..3ab97760e72 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;
+
 }