diff options
| author | seth <[email protected]> | 2024-03-20 02:28:43 -0400 |
|---|---|---|
| committer | seth <[email protected]> | 2024-03-20 06:34:42 +0000 |
| commit | faa038757ced955bb5c0a98dae7be6e7185af677 (patch) | |
| tree | 319cbd2e11cf74e2a464dbaf42370ec1f8eb57de /nix/static.nix | |
| parent | 362b80924010d0e425dc41885c8ee148f6d9ca36 (diff) | |
nix: cleanup derivation + static package
Diffstat (limited to 'nix/static.nix')
| -rw-r--r-- | nix/static.nix | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/nix/static.nix b/nix/static.nix new file mode 100644 index 0000000..22fbad6 --- /dev/null +++ b/nix/static.nix @@ -0,0 +1,38 @@ +{ + lib, + pkgsStatic, + fenix, + naersk, + teawiebot, +}: let + inherit (pkgsStatic.stdenv) cc; + + target = pkgsStatic.stdenv.hostPlatform.config; + target' = builtins.replaceStrings ["-"] ["_"] target; + targetUpper = lib.toUpper target'; + + toolchain = with fenix; + combine [ + minimal.cargo + minimal.rustc + targets.${target}.latest.rust-std + ]; + + naersk' = naersk.override { + cargo = toolchain; + rustc = toolchain; + }; +in + (teawiebot.override { + naersk = naersk'; + lto = true; + optimizeSize = true; + }) + .overrideAttrs (new: old: { + env = { + "CC_${target'}" = "${cc}/bin/${cc.targetPrefix}cc"; + CARGO_BUILD_TARGET = target; + CARGO_BUILD_RUSTFLAGS = old.env.CARGO_BUILD_RUSTFLAGS + " -C target-feature=+crt-static"; + "CARGO_TARGET_${targetUpper}_LINKER" = new.env."CC_${target'}"; + }; + }) |
