1/**
2 Instantiate the library tests for a given Nix version.
3
4 IMPORTANT:
5 This is used by the github.com/NixOS/nix CI.
6 This is used by Lix's CI (see flake.nix in the Lix repo).
7
8 Try not to change the interface of this file, or if you need to, ping the
9 Nix AND Lix maintainers (`nix eval -f . lib.teams.lix`) for help. Thank you!
10*/
11{
12 pkgs,
13 lib,
14 # Only ever use this nix; see comment at top
15 nix,
16}:
17
18pkgs.runCommand "nixpkgs-lib-tests-nix-${nix.version}"
19 {
20 buildInputs = [
21 (import ../path/tests {
22 inherit pkgs;
23 })
24 ];
25 nativeBuildInputs = [
26 nix
27 pkgs.gitMinimal
28 ]
29 ++ lib.optional pkgs.stdenv.hostPlatform.isLinux pkgs.inotify-tools;
30 strictDeps = true;
31 }
32 ''
33 datadir="${nix}/share"
34 export TEST_ROOT=$(pwd)/test-tmp
35 export HOME=$(mktemp -d)
36 export NIX_BUILD_HOOK=
37 export NIX_CONF_DIR=$TEST_ROOT/etc
38 export NIX_LOCALSTATE_DIR=$TEST_ROOT/var
39 export NIX_LOG_DIR=$TEST_ROOT/var/log/nix
40 export NIX_STATE_DIR=$TEST_ROOT/var/nix
41 export NIX_STORE_DIR=$TEST_ROOT/store
42 export PAGER=cat
43 cacheDir=$TEST_ROOT/binary-cache
44
45 nix-store --init
46
47 cp -r ${../.} lib
48 echo "Running lib/tests/modules.sh"
49 bash lib/tests/modules.sh
50
51 echo "Checking lib.version"
52 nix-instantiate lib -A version --eval || {
53 echo "lib.version does not evaluate when lib is isolated from the rest of the nixpkgs tree"
54 exit 1
55 }
56
57 echo "Running lib/tests/filesystem.sh"
58 TEST_LIB=$PWD/lib bash lib/tests/filesystem.sh
59
60 echo "Running lib/tests/sources.sh"
61 TEST_LIB=$PWD/lib bash lib/tests/sources.sh
62
63 echo "Running lib/tests/network.sh"
64 TEST_LIB=$PWD/lib bash lib/tests/network.sh
65
66 echo "Running lib/fileset/tests.sh"
67 TEST_LIB=$PWD/lib bash lib/fileset/tests.sh
68
69 echo "Running lib/tests/systems.nix"
70 [[ $(nix-instantiate --eval --strict lib/tests/systems.nix | tee /dev/stderr) == '[ ]' ]];
71
72 echo "Running lib/tests/misc.nix"
73 [[ $(nix-instantiate --eval --strict lib/tests/misc.nix | tee /dev/stderr) == '[ ]' ]];
74
75 echo "Running lib/tests/fetchers.nix"
76 [[ $(nix-instantiate --eval --strict lib/tests/fetchers.nix | tee /dev/stderr) == '[ ]' ]];
77
78 mkdir $out
79 echo success > $out/${nix.version}
80 ''