diff options
author | Alyssa Ross <hi@alyssa.is> | 2024-01-20 12:31:50 +0100 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2024-01-20 12:32:25 +0100 |
commit | b7baf40e099b4215181fe7b0c63083b12ef2c7fb (patch) | |
tree | a6efabd31d05b6d0a36624729e80377bbbfb0149 /nixpkgs/pkgs/test/nixpkgs-check-by-name/default.nix | |
parent | 710028664e26e85cb831a869b3da9f6993902255 (diff) | |
parent | 0799f514b1cd74878174939df79ac60ca5036673 (diff) | |
download | nixlib-b7baf40e099b4215181fe7b0c63083b12ef2c7fb.tar nixlib-b7baf40e099b4215181fe7b0c63083b12ef2c7fb.tar.gz nixlib-b7baf40e099b4215181fe7b0c63083b12ef2c7fb.tar.bz2 nixlib-b7baf40e099b4215181fe7b0c63083b12ef2c7fb.tar.lz nixlib-b7baf40e099b4215181fe7b0c63083b12ef2c7fb.tar.xz nixlib-b7baf40e099b4215181fe7b0c63083b12ef2c7fb.tar.zst nixlib-b7baf40e099b4215181fe7b0c63083b12ef2c7fb.zip |
Merge branch 'nixos-unstable-small' of https://github.com/NixOS/nixpkgs
Conflicts: nixpkgs/pkgs/build-support/rust/build-rust-package/default.nix
Diffstat (limited to 'nixpkgs/pkgs/test/nixpkgs-check-by-name/default.nix')
-rw-r--r-- | nixpkgs/pkgs/test/nixpkgs-check-by-name/default.nix | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/nixpkgs/pkgs/test/nixpkgs-check-by-name/default.nix b/nixpkgs/pkgs/test/nixpkgs-check-by-name/default.nix index fc24b1fd3398..8836da1f403f 100644 --- a/nixpkgs/pkgs/test/nixpkgs-check-by-name/default.nix +++ b/nixpkgs/pkgs/test/nixpkgs-check-by-name/default.nix @@ -6,13 +6,41 @@ clippy, mkShell, makeWrapper, + runCommand, }: let runtimeExprPath = ./src/eval.nix; + nixpkgsLibPath = ../../../lib; + testNixpkgsPath = ./tests/mock-nixpkgs.nix; + + # Needed to make Nix evaluation work inside nix builds + initNix = '' + export TEST_ROOT=$(pwd)/test-tmp + export NIX_CONF_DIR=$TEST_ROOT/etc + export NIX_LOCALSTATE_DIR=$TEST_ROOT/var + export NIX_LOG_DIR=$TEST_ROOT/var/log/nix + export NIX_STATE_DIR=$TEST_ROOT/var/nix + export NIX_STORE_DIR=$TEST_ROOT/store + + # Ensure that even if tests run in parallel, we don't get an error + # We'd run into https://github.com/NixOS/nix/issues/2706 unless the store is initialised first + nix-store --init + ''; + + fs = lib.fileset; + package = rustPlatform.buildRustPackage { name = "nixpkgs-check-by-name"; - src = lib.cleanSource ./.; + src = fs.toSource { + root = ./.; + fileset = fs.unions [ + ./Cargo.lock + ./Cargo.toml + ./src + ./tests + ]; + }; cargoLock.lockFile = ./Cargo.lock; nativeBuildInputs = [ nix @@ -21,19 +49,8 @@ let makeWrapper ]; env.NIX_CHECK_BY_NAME_EXPR_PATH = "${runtimeExprPath}"; - # Needed to make Nix evaluation work inside the nix build - preCheck = '' - export TEST_ROOT=$(pwd)/test-tmp - export NIX_CONF_DIR=$TEST_ROOT/etc - export NIX_LOCALSTATE_DIR=$TEST_ROOT/var - export NIX_LOG_DIR=$TEST_ROOT/var/log/nix - export NIX_STATE_DIR=$TEST_ROOT/var/nix - export NIX_STORE_DIR=$TEST_ROOT/store - - # Ensure that even if tests run in parallel, we don't get an error - # We'd run into https://github.com/NixOS/nix/issues/2706 unless the store is initialised first - nix-store --init - ''; + env.NIX_PATH = "test-nixpkgs=${testNixpkgsPath}:test-nixpkgs/lib=${nixpkgsLibPath}"; + preCheck = initNix; postCheck = '' cargo fmt --check cargo clippy -- -D warnings @@ -44,8 +61,22 @@ let ''; passthru.shell = mkShell { env.NIX_CHECK_BY_NAME_EXPR_PATH = toString runtimeExprPath; + env.NIX_PATH = "test-nixpkgs=${toString testNixpkgsPath}:test-nixpkgs/lib=${toString nixpkgsLibPath}"; inputsFrom = [ package ]; }; + + # Tests the tool on the current Nixpkgs tree, this is a good sanity check + passthru.tests.nixpkgs = runCommand "test-nixpkgs-check-by-name" { + nativeBuildInputs = [ + package + nix + ]; + nixpkgsPath = lib.cleanSource ../../..; + } '' + ${initNix} + nixpkgs-check-by-name --base "$nixpkgsPath" "$nixpkgsPath" + touch $out + ''; }; in package |