idiosyn/overlay/mimalloc.nix
Mikael Voss d9f5613b1b
Some checks are pending
nix flake check / check (aarch64-linux) (push) Waiting to run
nix flake check / check (x86_64-linux) (push) Waiting to run
Build with LLVM and musl
2024-10-24 12:15:03 +02:00

51 lines
1.6 KiB
Nix

{ nixpkgs, ... }: final: prev:
let
inherit (nixpkgs) lib;
in {
mimalloc = (prev.mimalloc.overrideAttrs (prevAttrs: {
overrideAlloc = false;
postPatch = prevAttrs.postPatch or "" + ''
sed -E -i \
-e 's/(\{ )1(, UNINIT, MI_OPTION_LEGACY\(purge_decommits,reset_decommits\) \})/\10\2/' \
-e 's/(\{ )0(, UNINIT, MI_OPTION_LEGACY\(allow_large_os_pages,large_os_pages\) \})/\11\2/' \
-e 's/(\{ )10(, UNINIT, MI_OPTION_LEGACY\(purge_delay,reset_delay\) \})/\150\2/' \
src/options.c
'';
})).override {
secureBuild = true;
};
firefox = (final.wrapFirefox final.firefox-unwrapped { }).overrideAttrs (prevAttrs: {
buildCommand = prevAttrs.buildCommand + ''
sed -i \
'$i export MIMALLOC_RESERVE_HUGE_OS_PAGES=2' \
"$out/bin/firefox"
'';
});
thunderbird = (final.wrapThunderbird final.thunderbird-unwrapped { }).overrideAttrs (prevAttrs: {
buildCommand = prevAttrs.buildCommand + ''
sed -i \
'$i export MIMALLOC_RESERVE_HUGE_OS_PAGES=2' \
"$out/bin/thunderbird"
'';
});
fractal = prev.fractal.overrideAttrs (prevAttrs: {
nativeBuildInputs = prevAttrs.nativeBuildInputs or [ ] ++ [ final.makeBinaryWrapper ];
postInstall = prevAttrs.postInstall or "" + ''
wrapProgram "$out/bin/fractal" \
--set MIMALLOC_RESERVE_HUGE_OS_PAGES 1
'';
});
mpv = final.mpv-unwrapped.wrapper {
mpv = final.mpv-unwrapped;
extraMakeWrapperArgs = [ "--set" "MIMALLOC_RESERVE_HUGE_OS_PAGES" "1" ];
};
perl = prev.perl.overrideAttrs {
overrideAlloc = false;
};
}