neosyn/overlays/alloc.nix
2024-12-04 23:41:39 +01:00

39 lines
1,004 B
Nix

final: prev:
let
inherit (prev) lib;
inherit (lib)
mapAttrsToList
concatStringsSep
extendDrvAttrs
extendDrvEnv;
in {
mimalloc = let
mimalloc = prev.mimalloc |> extendDrvAttrs {
cmakeFlags = let
cppdefs = {
MI_DEFAULT_EAGER_COMMIT = 0;
MI_DEFAULT_ALLOW_LARGE_OS_PAGES = 1;
} |> mapAttrsToList (name: value: "${name}=${toString value}")
|> concatStringsSep ";";
in [ ''-DMI_EXTRA_CPPDEFS="${cppdefs}"'' ];
};
in mimalloc.override { secureBuild = true; };
# incompatible allocators
gperftools = null;
jemalloc = null;
rust-jemalloc-sys = null;
# individual packages
conduwuit = prev.conduwuit.override { enableJemalloc = false; };
sqlite = prev.sqlite |> extendDrvEnv {
NIX_CFLAGS_COMPILE = [
"-DSQLITE_DEFAULT_PAGE_SIZE=2097152"
"-DSQLITE_DEFAULT_CACHE_SIZE=-64"
"-DSQLITE_DEFAULT_PCACHE_INITSZ=1"
"-DSQLITE_MALLOC_SOFT_LIMIT=0"
"-DSQLITE_USE_ALLOCA"
];
};
}