···11`rootPaths` must be a list of derivations.
12The transitive closure of these derivations' outputs will be copied into the cache.
130000000014::: {.note}
15This function is meant for advanced use cases.
16The more idiomatic way to work with flat-file binary caches is via the [nix-copy-closure](https://nixos.org/manual/nix/stable/command-ref/nix-copy-closure.html) command.
···11`rootPaths` must be a list of derivations.
12The transitive closure of these derivations' outputs will be copied into the cache.
1314+## Optional arguments {#sec-pkgs-binary-cache-arguments}
15+16+`compression` (`"none"` or `"xz"` or `"zstd"`; _optional_)
17+18+: The compression algorithm to use.
19+20+ _Default value:_ `zstd`.
21+22::: {.note}
23This function is meant for advanced use cases.
24The more idiomatic way to work with flat-file binary caches is via the [nix-copy-closure](https://nixos.org/manual/nix/stable/command-ref/nix-copy-closure.html) command.
···6 python3,
7 nix,
8 xz,
09}:
1011# This function is for creating a flat-file binary cache, i.e. the kind created by
···1617{
18 name ? "binary-cache",
019 rootPaths,
20}:
2100000022stdenv.mkDerivation {
23 inherit name;
24···2829 preferLocalBuild = true;
3031- nativeBuildInputs = [
32- coreutils
33- jq
34- python3
35- nix
36- xz
37- ];
003839 buildCommand = ''
40 mkdir -p $out/nar
4142- python ${./make-binary-cache.py}
4344 # These directories must exist, or Nix might try to create them in LocalBinaryCacheStore::init(),
45 # which fails if mounted read-only
···6 python3,
7 nix,
8 xz,
9+ zstd,
10}:
1112# This function is for creating a flat-file binary cache, i.e. the kind created by
···1718{
19 name ? "binary-cache",
20+ compression ? "zstd", # one of ["none" "xz" "zstd"]
21 rootPaths,
22}:
2324+assert lib.elem compression [
25+ "none"
26+ "xz"
27+ "zstd"
28+];
29+30stdenv.mkDerivation {
31 inherit name;
32···3637 preferLocalBuild = true;
3839+ nativeBuildInputs =
40+ [
41+ coreutils
42+ jq
43+ python3
44+ nix
45+ ]
46+ ++ lib.optional (compression == "xz") xz
47+ ++ lib.optional (compression == "zstd") zstd;
4849 buildCommand = ''
50 mkdir -p $out/nar
5152+ python ${./make-binary-cache.py} --compression "${compression}"
5354 # These directories must exist, or Nix might try to create them in LocalBinaryCacheStore::init(),
55 # which fails if mounted read-only