nix: improve RUSTFLAGS + add overlay
This commit is contained in:
parent
0b0779f8b7
commit
5cfb079e35
4 changed files with 22 additions and 13 deletions
|
@ -47,9 +47,3 @@ pedantic = "warn"
|
||||||
perf = "warn"
|
perf = "warn"
|
||||||
style = "warn"
|
style = "warn"
|
||||||
suspicious = "deny"
|
suspicious = "deny"
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
codegen-units = 1
|
|
||||||
opt-level = "s"
|
|
||||||
panic = "abort"
|
|
||||||
strip = "symbols"
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
buildWith = rustPlatform:
|
buildWith = rustPlatform:
|
||||||
self'.packages.refraction.override {
|
self'.packages.refraction.override {
|
||||||
inherit rustPlatform;
|
inherit rustPlatform;
|
||||||
lto = true;
|
optimizeSize = true;
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
packages =
|
packages =
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
rustPlatform,
|
rustPlatform,
|
||||||
darwin,
|
darwin,
|
||||||
self,
|
self,
|
||||||
lto ? false,
|
lto ? true,
|
||||||
|
optimizeSize ? false,
|
||||||
}:
|
}:
|
||||||
rustPlatform.buildRustPackage {
|
rustPlatform.buildRustPackage {
|
||||||
pname = "refraction";
|
pname = "refraction";
|
||||||
|
@ -35,11 +36,22 @@ rustPlatform.buildRustPackage {
|
||||||
SystemConfiguration
|
SystemConfiguration
|
||||||
]);
|
]);
|
||||||
|
|
||||||
env = {
|
env = let
|
||||||
CARGO_BUILD_RUSTFLAGS = lib.concatStringsSep " " (
|
toRustFlags = lib.mapAttrs' (
|
||||||
lib.optionals lto ["-C" "lto=thin" "-C" "embed-bitcode=yes" "-Zdylib-lto"]
|
name:
|
||||||
|
lib.nameValuePair
|
||||||
|
"CARGO_PROFILE_RELEASE_${lib.toUpper (builtins.replaceStrings ["-"] ["_"] name)}"
|
||||||
);
|
);
|
||||||
};
|
in
|
||||||
|
lib.optionalAttrs lto (toRustFlags {
|
||||||
|
lto = "thin";
|
||||||
|
})
|
||||||
|
// lib.optionalAttrs optimizeSize (toRustFlags {
|
||||||
|
codegen-units = "1";
|
||||||
|
opt-level = "s";
|
||||||
|
panic = "abort";
|
||||||
|
strip = "symbols";
|
||||||
|
});
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
mainProgram = "refraction";
|
mainProgram = "refraction";
|
||||||
|
|
|
@ -6,8 +6,11 @@
|
||||||
}: {
|
}: {
|
||||||
packages = {
|
packages = {
|
||||||
refraction = pkgs.callPackage ./derivation.nix {inherit self;};
|
refraction = pkgs.callPackage ./derivation.nix {inherit self;};
|
||||||
|
|
||||||
default = self'.packages.refraction;
|
default = self'.packages.refraction;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
flake.overlays.default = _: prev: {
|
||||||
|
refraction = prev.callPackage ./derivation.nix {inherit self;};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue