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"
|
||||
style = "warn"
|
||||
suspicious = "deny"
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1
|
||||
opt-level = "s"
|
||||
panic = "abort"
|
||||
strip = "symbols"
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
buildWith = rustPlatform:
|
||||
self'.packages.refraction.override {
|
||||
inherit rustPlatform;
|
||||
lto = true;
|
||||
optimizeSize = true;
|
||||
};
|
||||
in {
|
||||
packages =
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -6,8 +6,11 @@
|
|||
}: {
|
||||
packages = {
|
||||
refraction = pkgs.callPackage ./derivation.nix {inherit self;};
|
||||
|
||||
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