-
Notifications
You must be signed in to change notification settings - Fork 14
/
package.nix
69 lines (58 loc) · 1.37 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
{
stdenv,
pkgs,
rustPlatform,
nix-gitignore,
enableClippy ? false,
}:
let
libDir =
if
builtins.elem stdenv.system [
"x86_64-linux"
"mips64-linux"
"powerpc64le-linux"
]
then
"/lib64"
else
"/lib";
nix-ld = rustPlatform.buildRustPackage {
name = "nix-ld";
cargoLock.lockFile = ./Cargo.lock;
src = nix-gitignore.gitignoreSource [ ] ./.;
hardeningDisable = [ "stackprotector" ];
NIX_SYSTEM = stdenv.system;
RUSTC_BOOTSTRAP = "1";
preCheck = ''
export NIX_LD=${stdenv.cc.bintools.dynamicLinker}
'';
postInstall = ''
mkdir -p $out/libexec
ln -s $out/bin/nix-ld $out/libexec/nix-ld
mkdir -p $out/nix-support
ldpath=${libDir}/$(basename ${stdenv.cc.bintools.dynamicLinker})
echo "$ldpath" > $out/nix-support/ldpath
mkdir -p $out/lib/tmpfiles.d/
cat > $out/lib/tmpfiles.d/nix-ld.conf <<EOF
L+ $ldpath - - - - $out/libexec/nix-ld
EOF
'';
passthru.tests = import ./nixos-tests { inherit pkgs nix-ld; };
};
in
if enableClippy then
nix-ld.overrideAttrs (oldAttrs: {
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ pkgs.clippy ];
phases = [
"unpackPhase"
"patchPhase"
"installPhase"
];
installPhase = ''
cargo clippy -- -D warnings
touch $out
'';
})
else
nix-ld