refraction/nix/static.nix
seth 55bc54722e perf(nix): refactor mkStatic
this should speed up evaluation a bit by caching all the things
2024-11-12 08:27:23 +01: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;
};
})