-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.nix
84 lines (75 loc) · 2.1 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
76
77
78
79
80
81
82
83
84
{
lib,
stdenv,
rustPlatform,
makeBinaryWrapper,
installShellFiles,
nix-output-monitor,
nvd,
self,
enableLTO ? true,
enableOptimizeSize ? false,
withNom ? true,
withNvd ? true,
}:
let
year = builtins.substring 0 4 self.lastModifiedDate;
month = builtins.substring 4 2 self.lastModifiedDate;
day = builtins.substring 6 2 self.lastModifiedDate;
in
rustPlatform.buildRustPackage (finalAttrs: {
pname = finalAttrs.passthru.cargoToml.package.name;
version = "${finalAttrs.passthru.cargoToml.package.version}-unstable-${year}-${month}-${day}";
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./src
./Cargo.lock
./Cargo.toml
];
};
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = [
makeBinaryWrapper
installShellFiles
];
postInstall =
let
wrapBins = (lib.optional withNom nix-output-monitor) ++ (lib.optional withNvd nvd);
in
''
${lib.optionalString (withNom || withNvd) ''
wrapProgram $out/bin/${finalAttrs.pname} \
--suffix PATH : ${lib.makeBinPath wrapBins}
''}
${lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
installShellCompletion --cmd ${finalAttrs.pname} \
--bash <("$out/bin/${finalAttrs.pname}" completions bash) \
--zsh <("$out/bin/${finalAttrs.pname}" completions zsh) \
--fish <("$out/bin/${finalAttrs.pname}" completions fish)
''}
'';
doCheck = false;
env =
lib.optionalAttrs enableLTO {
CARGO_PROFILE_RELEASE_LTO = "fat";
CARGO_PROFILE_RELEASE_CODEGEN_UNITS = "1";
}
// lib.optionalAttrs enableOptimizeSize {
CARGO_PROFILE_RELEASE_OPT_LEVEL = "z";
CARGO_PROFILE_RELEASE_PANIC = "abort";
CARGO_PROFILE_RELEASE_CODEGEN_UNITS = "1";
CARGO_PROFILE_RELEASE_STRIP = "symbols";
};
passthru = {
cargoToml = lib.importTOML ./Cargo.toml;
};
meta = with lib; {
description = "nix-darwin utilities";
maintainers = with maintainers; [ ryanccn ];
license = licenses.gpl3Only;
mainProgram = "morlana";
};
})