-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
package.nix
75 lines (64 loc) · 1.42 KB
/
package.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{
lib,
rustPlatform,
path,
nix,
nixVersions,
lixVersions,
clippy,
makeWrapper,
nixVersionsToTest ? [
nix
nixVersions.stable
nixVersions.minimum
nixVersions.latest
lixVersions.stable
lixVersions.latest
],
initNix,
version,
}:
let
fs = lib.fileset;
in
rustPlatform.buildRustPackage {
pname = "nixpkgs-vet";
inherit version;
src = fs.toSource {
root = ./.;
fileset = fs.unions [
./Cargo.lock
./Cargo.toml
./src
./tests
];
};
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = [
clippy
makeWrapper
];
env.NIXPKGS_VET_NIX_PACKAGE = lib.getBin nix;
env.NIXPKGS_VET_NIXPKGS_LIB = "${path}/lib";
checkPhase = ''
# This path will be symlinked to the current version that is being tested
nixPackage=$(mktemp -d)/nix
# For initNix
export PATH=$nixPackage/bin:$PATH
# This is what nixpkgs-vet uses
export NIXPKGS_VET_NIX_PACKAGE=$nixPackage
${lib.concatMapStringsSep "\n" (nix: ''
ln -s ${lib.getBin nix} "$nixPackage"
echo "Testing with $(nix --version)"
${initNix}
runHook cargoCheckHook
rm "$nixPackage"
'') (lib.unique nixVersionsToTest)}
# --tests or --all-targets include tests for linting
cargo clippy --all-targets -- -D warnings
'';
postInstall = ''
wrapProgram $out/bin/nixpkgs-vet \
--set NIXPKGS_VET_NIX_PACKAGE ${lib.getBin nix}
'';
}