Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ # The pkgs used for dependencies for the testing itself
2 # Don't test properties of pkgs.lib, but rather the lib in the parent directory
3 pkgs ? import ../.. {} // { lib = throw "pkgs.lib accessed, but the lib tests should use nixpkgs' lib path directly!"; },
4 nix ? pkgs.nix,
5 nixVersions ? [ pkgs.nixVersions.minimum nix pkgs.nixVersions.unstable ],
6}:
7
8let
9 lib = import ../.;
10 testWithNix = nix:
11 pkgs.runCommand "nixpkgs-lib-tests-nix-${nix.version}" {
12 buildInputs = [
13 (import ./check-eval.nix)
14 (import ./maintainers.nix {
15 inherit pkgs;
16 lib = import ../.;
17 })
18 (import ./teams.nix {
19 inherit pkgs;
20 lib = import ../.;
21 })
22 (import ../path/tests {
23 inherit pkgs;
24 })
25 ];
26 nativeBuildInputs = [
27 nix
28 ] ++ lib.optional pkgs.stdenv.isLinux pkgs.inotify-tools;
29 strictDeps = true;
30 } ''
31 datadir="${nix}/share"
32 export TEST_ROOT=$(pwd)/test-tmp
33 export NIX_BUILD_HOOK=
34 export NIX_CONF_DIR=$TEST_ROOT/etc
35 export NIX_LOCALSTATE_DIR=$TEST_ROOT/var
36 export NIX_LOG_DIR=$TEST_ROOT/var/log/nix
37 export NIX_STATE_DIR=$TEST_ROOT/var/nix
38 export NIX_STORE_DIR=$TEST_ROOT/store
39 export PAGER=cat
40 cacheDir=$TEST_ROOT/binary-cache
41
42 nix-store --init
43
44 cp -r ${../.} lib
45 echo "Running lib/tests/modules.sh"
46 bash lib/tests/modules.sh
47
48 echo "Running lib/tests/filesystem.sh"
49 TEST_LIB=$PWD/lib bash lib/tests/filesystem.sh
50
51 echo "Running lib/tests/sources.sh"
52 TEST_LIB=$PWD/lib bash lib/tests/sources.sh
53
54 echo "Running lib/fileset/tests.sh"
55 TEST_LIB=$PWD/lib bash lib/fileset/tests.sh
56
57 echo "Running lib/tests/systems.nix"
58 [[ $(nix-instantiate --eval --strict lib/tests/systems.nix | tee /dev/stderr) == '[ ]' ]];
59
60 mkdir $out
61 echo success > $out/${nix.version}
62 '';
63
64in
65 pkgs.symlinkJoin {
66 name = "nixpkgs-lib-tests";
67 paths = map testWithNix nixVersions;
68 }