ccache
This commit is contained in:
+81
-4
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env -S nix-instantiate --parse
|
||||
let
|
||||
lib = import ./master/lib;
|
||||
forBuildHost = p: p.__spliced.buildHost or p;
|
||||
# merge = sets: lib.foldl' lib.recursiveUpdate {} sets;
|
||||
appendIfMissing = list: val: if builtins.elem val list then list else list ++ [ val ];
|
||||
|
||||
@@ -43,7 +44,7 @@ let
|
||||
# extendDrvArgs = f final prev stdenv;
|
||||
# };
|
||||
mkDerivationFromStdenv = extendMkDerivationArgs stdenv (
|
||||
finalAttrs: prevAttrs: # TODO: drop finalAttrs?
|
||||
finalAttrs: prevAttrs:
|
||||
lib.optionalAttrs (!(lib.strings.hasInfix "bootstrap" stdenv.name)) (
|
||||
let
|
||||
stdenv' = stdenv // {
|
||||
@@ -274,6 +275,82 @@ let
|
||||
);
|
||||
};
|
||||
|
||||
# usage: nix-build ./dev.nix -A <package>.withCcache
|
||||
overlays.withCcache =
|
||||
let
|
||||
ccacheConfig = ''
|
||||
export CCACHE_DIR=/var/cache/ccache
|
||||
export CCACHE_UMASK=007
|
||||
export CCACHE_COMPRESS=1
|
||||
|
||||
# may break reproducibility or cause cache poisoning
|
||||
# https://wiki.nixos.org/wiki/CCache#Sloppiness
|
||||
# https://github.com/NixOS/nixpkgs/issues/109033
|
||||
export CCACHE_SLOPPINESS=random_seed
|
||||
|
||||
if [[ ! -d "$CCACHE_DIR" ]]; then
|
||||
echo "ERROR: \$CCACHE_DIR=$CCACHE_DIR not found!"
|
||||
exit 1
|
||||
elif [[ ! -w "$CCACHE_DIR" ]]; then
|
||||
echo "ERROR: \$CCACHE_DIR=$CCACHE_DIR not writeable!"
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
in
|
||||
final: prev:
|
||||
{
|
||||
ccacheWrapper = prev.ccacheWrapper.override {
|
||||
extraConfig = ccacheConfig;
|
||||
};
|
||||
|
||||
# TODO: swap to this scope if in cudaPackages withCcache
|
||||
# cudaPackages' = final.cudaPackages.overrideScope (
|
||||
# cudaFinal: cudaPrev: {
|
||||
# cuda_nvcc = cudaPrev.cuda_nvcc.overrideAttrs (oldAttrs: {
|
||||
# nativeBuildInputs = oldAttrs.nativeBuildInputs or [ ] ++ [ final.makeWrapper ];
|
||||
# postFixup =
|
||||
# oldAttrs.postFixup or ""
|
||||
# + ''
|
||||
# mv "$out/bin/nvcc" "$out/bin/.nvcc-no-ccache"
|
||||
# args=(
|
||||
# "${prev.lib.getExe (forBuildHost final.ccache)}"
|
||||
# "$out/bin/nvcc"
|
||||
# --run ${prev.lib.escapeShellArg ccacheConfig}
|
||||
# --add-flags "$out/bin/.nvcc-no-ccache"
|
||||
# )
|
||||
# makeWrapper "''${args[@]}"
|
||||
# '';
|
||||
# });
|
||||
# }
|
||||
# );
|
||||
|
||||
# pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [
|
||||
# (pythonFinal: pythonPrev: {
|
||||
# })
|
||||
# ];
|
||||
}
|
||||
// (mkDerivationOverlay (final: prev: prevStdenv: finalAttrs: prevAttrs: {
|
||||
passthru = {
|
||||
# withCcache = prevStdenv.mkDerivation (
|
||||
withCcache = prev.ccacheStdenv.mkDerivation (
|
||||
{
|
||||
requiredSystemFeatures = prevAttrs.requiredSystemFeatures or [ ] ++ [
|
||||
"ccache"
|
||||
# "sccache"
|
||||
];
|
||||
# RUSTC_WRAPPER = lib.getExe final.sccache;
|
||||
# SCCACHE_DIR = "/var/cache/sccache";
|
||||
# # SCCACHE_REDIS_ENDPOINT = "redis+unix://run/redis-nix-sccache/redis.sock";
|
||||
# # SCCACHE_IDLE_TIMEOUT = 0;
|
||||
# SCCACHE_CACHE_ZSTD_LEVEL = 19;
|
||||
# # SCCACHE_LOG = "debug";
|
||||
# # SCCACHE_NO_DAEMON = true;
|
||||
}
|
||||
// prevAttrs
|
||||
);
|
||||
} // prevAttrs.passthru or { };
|
||||
}) final prev);
|
||||
|
||||
# very hacky, not guaranteed to work, but may save a lot of .whl rebuilds
|
||||
# usage: nix-build ./dev.nix -A python3Packages.<package>.twostage
|
||||
# usage: nix-build ./dev.nix -A python3Packages.<package>.twostage.first
|
||||
@@ -439,14 +516,14 @@ let
|
||||
|
||||
in
|
||||
[
|
||||
overlays.withShellCheck
|
||||
overlays.withDebug
|
||||
overlays.srcOnly
|
||||
overlays.withInvalidateFetcherByDrvHash
|
||||
overlays.withUnpacked
|
||||
overlays.withShellCheck
|
||||
# overlays.withCudaOrRocm # WIP
|
||||
overlays.withCcache # WIP
|
||||
overlays.withTwostagePythonBuildPassthru
|
||||
overlays.withPytestCheckHooks
|
||||
overlays.toplevelCudaRocmPkgs
|
||||
# WIP:
|
||||
# overlays.withCudaOrRocm
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user