-
Notifications
You must be signed in to change notification settings - Fork 1
/
default.nix
43 lines (41 loc) · 929 Bytes
/
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
{
nixpkgs,
systemConfig,
fenix,
naersk,
}: let
system = systemConfig.system;
pkgs = nixpkgs.legacyPackages."${system}";
target = systemConfig.rust_target;
toolchain = with fenix.packages.${system};
combine [
stable.cargo
stable.rustc
targets.${target}.stable.rust-std
];
naersk' = naersk.lib.${system}.override {
cargo = toolchain;
rustc = toolchain;
};
cc =
if systemConfig.static
then pkgs.pkgsStatic.stdenv.cc
else pkgs.stdenv.cc;
in rec {
uncompressed = naersk'.buildPackage {
src = ./.;
CARGO_BUILD_TARGET = target;
TARGET_CC = "${cc}/bin/${cc.targetPrefix}cc";
nativeBuildInputs = [cc];
};
compressed =
pkgs.runCommand "compressed" {
nativeBuildInputs = [pkgs.upx];
} ''
mkdir -p $out/bin
cp ${uncompressed}/bin/* $out/bin/
chmod +w $out/bin/*
upx $out/bin/*
'';
default = compressed;
}