blob: fa4867a3fb9cdaa4b33cc3a16bfc2fa02cdf82cc (
plain)
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
|
{
lib,
stdenv,
rustPlatform,
darwin,
self,
lto ? true,
optimizeSize ? false,
}:
rustPlatform.buildRustPackage {
pname = "teawiebot";
version =
(lib.importTOML ../Cargo.toml).package.version
+ "-${self.shortRev or self.dirtyShortRev or "unknown-dirty"}";
__structuredAttrs = true;
src = lib.fileset.toSource {
root = ../.;
fileset = lib.fileset.unions [
../src
../Cargo.toml
../Cargo.lock
];
};
cargoLock = {
lockFile = ../Cargo.lock;
};
buildInputs = lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
CoreFoundation
Security
SystemConfiguration
darwin.libiconv
]);
env = let
toRustFlags = lib.mapAttrs' (
name:
lib.nameValuePair
"CARGO_BUILD_RELEASE_${lib.toUpper (builtins.replaceStrings ["-"] ["_"] name)}"
);
in
{
GIT_SHA = self.shortRev or self.dirtyShortRev or "unknown-dirty";
}
// lib.optionalAttrs lto (toRustFlags {
lto = "thin";
})
// lib.optionalAttrs optimizeSize (toRustFlags {
codegen-units = 1;
opt-level = "s";
panic = "abort";
strip = "symbols";
});
meta = with lib; {
mainProgram = "teawiebot";
description = "funni bot";
homepage = "https://github.com/getchoo/teawiebot";
license = licenses.mit;
maintainers = with maintainers; [getchoo];
};
}
|