refraction/nix/static.nix
seth 4b57942c5b
perf(nix): refactor mkStatic
this should speed up evaluation a bit by caching all the things
2024-11-11 17:01:55 -05:00

37 lines
763 B
Nix

{
lib,
refraction,
rust-overlay,
pkgsCross,
}:
let
crossPlatformFor = with pkgsCross; {
x86_64 = musl64.pkgsStatic;
aarch64 = aarch64-multiplatform.pkgsStatic;
};
toolchain = rust-overlay.rust.minimal.override {
extensions = [ "rust-std" ];
targets = lib.mapAttrsToList (_: pkgs: pkgs.stdenv.hostPlatform.rust.rustcTarget) crossPlatformFor;
};
rustPlatformFor = lib.mapAttrs (
_: pkgs:
pkgs.makeRustPlatform (
lib.genAttrs [
"cargo"
"rustc"
] (_: toolchain)
)
) crossPlatformFor;
in
{ arch }:
(refraction.override {
rustPlatform = rustPlatformFor.${arch};
optimizeSize = true;
}).overrideAttrs
(old: {
passthru = old.passthru or { } // {
inherit toolchain;
};
})