CCache
ccache is useful for Packaging large packages with Incremental builds
with ccache, recompile time can be reduced from many hours to a few minutes
derivation ccache
to enable ccache only for one derivation
add to /etc/nixos/configuration.nix
nix.extraOptions = ''
sandbox = false
'';
run sudo nixos-rebuild switch
now /etc/nix/nix.conf should have sandbox = false
patch the default.nix file
{ stdenv
, ccacheStdenv
# ...
}:
#stdenv.mkDerivation {
ccacheStdenv.mkDerivation {
preConfigure = ''
export CCACHE_DIR=/var/cache/ccache
export CCACHE_UMASK=007
''
# ...
add ccacheStdenv to dependencies
run nix-build
system ccache
todo
monitor ccache status
# watch ccache size sudo watch du -sh /var/cache/ccache # watch ccache stats sudo watch ccache --dir /var/cache/ccache --show-stats --verbose