nix: improve RUSTFLAGS + add overlay
This commit is contained in:
parent
0b0779f8b7
commit
5cfb079e35
4 changed files with 22 additions and 13 deletions
|
@ -4,7 +4,8 @@
|
|||
rustPlatform,
|
||||
darwin,
|
||||
self,
|
||||
lto ? false,
|
||||
lto ? true,
|
||||
optimizeSize ? false,
|
||||
}:
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "refraction";
|
||||
|
@ -35,11 +36,22 @@ rustPlatform.buildRustPackage {
|
|||
SystemConfiguration
|
||||
]);
|
||||
|
||||
env = {
|
||||
CARGO_BUILD_RUSTFLAGS = lib.concatStringsSep " " (
|
||||
lib.optionals lto ["-C" "lto=thin" "-C" "embed-bitcode=yes" "-Zdylib-lto"]
|
||||
env = let
|
||||
toRustFlags = lib.mapAttrs' (
|
||||
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; {
|
||||
mainProgram = "refraction";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue