Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / test / nixpkgs-check-by-name / default.nix
blob0d4e2fcc48a781eca652de44e1f528b7e6509e13
2   lib,
3   rustPlatform,
4   nix,
5   rustfmt,
6   clippy,
7   mkShell,
8 }:
9 let
10   package =
11     rustPlatform.buildRustPackage {
12       name = "nixpkgs-check-by-name";
13       src = lib.cleanSource ./.;
14       cargoLock.lockFile = ./Cargo.lock;
15       nativeBuildInputs = [
16         nix
17         rustfmt
18         clippy
19       ];
20       # Needed to make Nix evaluation work inside the nix build
21       preCheck = ''
22         export TEST_ROOT=$(pwd)/test-tmp
23         export NIX_CONF_DIR=$TEST_ROOT/etc
24         export NIX_LOCALSTATE_DIR=$TEST_ROOT/var
25         export NIX_LOG_DIR=$TEST_ROOT/var/log/nix
26         export NIX_STATE_DIR=$TEST_ROOT/var/nix
27         export NIX_STORE_DIR=$TEST_ROOT/store
29         # Ensure that even if tests run in parallel, we don't get an error
30         # We'd run into https://github.com/NixOS/nix/issues/2706 unless the store is initialised first
31         nix-store --init
32       '';
33       postCheck = ''
34         cargo fmt --check
35         cargo clippy -- -D warnings
36       '';
37       passthru.shell = mkShell {
38         inputsFrom = [ package ];
39       };
40     };
42 package