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