Link against mimalloc by overriding stdenv
This commit is contained in:
parent
e1c265ca42
commit
b62fa094e9
|
@ -98,7 +98,10 @@
|
||||||
localSystem = builtins.currentSystem or platform;
|
localSystem = builtins.currentSystem or platform;
|
||||||
crossSystem = platform;
|
crossSystem = platform;
|
||||||
overlays = [ self.overlays.default ];
|
overlays = [ self.overlays.default ];
|
||||||
config.allowUnsupportedSystem = true;
|
config = {
|
||||||
|
allowUnsupportedSystem = true;
|
||||||
|
replaceStdenv = { pkgs }: self.lib.stdenv pkgs;
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
packages = eachSystem (system: platform:
|
packages = eachSystem (system: platform:
|
||||||
|
|
23
lib/stdenv.nix
Normal file
23
lib/stdenv.nix
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{ ... }: pkgs:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
inherit (lib) optionalAttrs toList;
|
||||||
|
|
||||||
|
ldflags = [ "-lmimalloc" ];
|
||||||
|
rustflags = map (flag: [ "-C" "link-arg=${flag}" ]) ldflags |> lib.flatten;
|
||||||
|
|
||||||
|
exclude = lib.genAttrs [
|
||||||
|
"mimalloc"
|
||||||
|
"perl"
|
||||||
|
] (pkg: null);
|
||||||
|
in pkgs.addAttrsToDerivation (prevAttrs: optionalAttrs (!exclude ? ${lib.getName prevAttrs}) ({
|
||||||
|
buildInputs = prevAttrs.buildInputs or [ ] ++ [ pkgs.mimalloc ];
|
||||||
|
env = prevAttrs.env or { } // optionalAttrs (prevAttrs ? env.NIX_LDFLAGS) {
|
||||||
|
NIX_LDFLAGS = toList prevAttrs.NIX_LDFLAGS or [ ] ++ ldflags |> toString;
|
||||||
|
};
|
||||||
|
|
||||||
|
NIX_RUSTFLAGS = prevAttrs.NIX_RUSTFLAGS or [ ] ++ rustflags;
|
||||||
|
} // optionalAttrs (!prevAttrs ? env.NIX_LDFLAGS) {
|
||||||
|
NIX_LDFLAGS = toList prevAttrs.NIX_LDFLAGS or [ ] ++ ldflags;
|
||||||
|
})) pkgs.stdenv
|
|
@ -33,10 +33,6 @@ in {
|
||||||
|
|
||||||
fractal = prev.fractal.overrideAttrs (prevAttrs: {
|
fractal = prev.fractal.overrideAttrs (prevAttrs: {
|
||||||
nativeBuildInputs = prevAttrs.nativeBuildInputs or [ ] ++ [ final.makeBinaryWrapper ];
|
nativeBuildInputs = prevAttrs.nativeBuildInputs or [ ] ++ [ final.makeBinaryWrapper ];
|
||||||
buildInputs = prevAttrs.buildInputs or [ ] ++ [ final.mimalloc ];
|
|
||||||
|
|
||||||
NIX_RUSTFLAGS = lib.toList prevAttrs.NIX_RUSTFLAGS or [ ] ++ [ "-C" "link-arg=-lmimalloc" ];
|
|
||||||
|
|
||||||
postInstall = prevAttrs.postInstall or "" + ''
|
postInstall = prevAttrs.postInstall or "" + ''
|
||||||
wrapProgram "$out/bin/fractal" \
|
wrapProgram "$out/bin/fractal" \
|
||||||
--set MIMALLOC_RESERVE_HUGE_OS_PAGES 1
|
--set MIMALLOC_RESERVE_HUGE_OS_PAGES 1
|
||||||
|
@ -47,47 +43,4 @@ in {
|
||||||
mpv = final.mpv-unwrapped;
|
mpv = final.mpv-unwrapped;
|
||||||
extraMakeWrapperArgs = [ "--set" "MIMALLOC_RESERVE_HUGE_OS_PAGES" "1" ];
|
extraMakeWrapperArgs = [ "--set" "MIMALLOC_RESERVE_HUGE_OS_PAGES" "1" ];
|
||||||
};
|
};
|
||||||
} // lib.genAttrs [
|
}
|
||||||
"bat"
|
|
||||||
"bottom"
|
|
||||||
"cryptsetup"
|
|
||||||
"dbus-broker"
|
|
||||||
"erlang"
|
|
||||||
"fd"
|
|
||||||
"firefox-unwrapped"
|
|
||||||
"fuzzel"
|
|
||||||
"helix"
|
|
||||||
"kitty"
|
|
||||||
"mako"
|
|
||||||
"mpv-unwrapped"
|
|
||||||
"niri"
|
|
||||||
"nix"
|
|
||||||
"nushell"
|
|
||||||
"openssh"
|
|
||||||
"pipewire"
|
|
||||||
"pueue"
|
|
||||||
"ripgrep"
|
|
||||||
"sd"
|
|
||||||
"sioyek"
|
|
||||||
"sudo-rs"
|
|
||||||
"systemd"
|
|
||||||
"swayidle"
|
|
||||||
"swaylock"
|
|
||||||
"swaylock-effects"
|
|
||||||
"thunderbird-unwrapped"
|
|
||||||
"uutils-coreutils"
|
|
||||||
"uutils-coreutils-noprefix"
|
|
||||||
"waybar"
|
|
||||||
"wirepluber"
|
|
||||||
"xdg-desktop-portal-gnome"
|
|
||||||
"xdg-desktop-portal-gtk"
|
|
||||||
] (pkg: prev.${pkg}.overrideAttrs (prevAttrs: {
|
|
||||||
buildInputs = prevAttrs.buildInputs or [ ] ++ [ final.mimalloc ];
|
|
||||||
env = prevAttrs.env or { } // lib.optionalAttrs (prevAttrs ? env.NIX_LDFLAGS) {
|
|
||||||
NIX_LDFLAGS = toString (lib.toList prevAttrs.env.NIX_LDFLAGS or [ ] ++ [ "-lmimalloc" ]);
|
|
||||||
};
|
|
||||||
|
|
||||||
NIX_RUSTFLAGS = lib.toList prevAttrs.NIX_RUSTFLAGS or [ ] ++ [ "-C" "link-arg=-lmimalloc" ];
|
|
||||||
} // lib.optionalAttrs (!prevAttrs ? env.NIX_LDFLAGS) {
|
|
||||||
NIX_LDFLAGS = lib.toList prevAttrs.NIX_LDFLAGS or [ ] ++ [ "-lmimalloc" ];
|
|
||||||
}))
|
|
||||||
|
|
Loading…
Reference in a new issue