-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
93 lines (82 loc) · 2.1 KB
/
default.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
85
86
87
88
89
90
91
92
93
{
lib,
stdenv,
rustPlatform,
darwin,
makeBinaryWrapper,
installShellFiles,
nix-output-monitor,
nvd,
nix-filter,
pkg-config,
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 rec {
pname = passthru.cargoToml.package.name;
version = passthru.cargoToml.package.version + "-unstable-${year}-${month}-${day}";
strictDeps = true;
src = nix-filter.lib.filter {
root = self;
include = [
"src"
"Cargo.lock"
"Cargo.toml"
];
};
cargoLock = {
lockFile = ./Cargo.lock;
};
buildInputs = lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.IOKit
darwin.libiconv
];
nativeBuildInputs = [
makeBinaryWrapper
installShellFiles
pkg-config
];
postInstall =
let
wrapBins = (lib.optional withNom nix-output-monitor) ++ (lib.optional withNvd nvd);
in
''
wrapProgram $out/bin/morlana \
--suffix PATH : ${lib.makeBinPath wrapBins}
installShellCompletion --cmd ${pname} \
--bash <("$out/bin/${pname}" completions bash) \
--zsh <("$out/bin/${pname}" completions zsh) \
--fish <("$out/bin/${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";
};
}