query
On this page

mkBinaryCache

pkgs.mkBinaryCache

Functor
Docs pulled from | This Revision | 26 minutes ago


Contribute
Enhance the ecosystem with your expertise! Contribute to fill the gaps in documentation. Your input can make a difference.

Noogle detected

This is a Functor

Learn about functors

Implementation

The following is the current implementation of this function.

{
  name ? "binary-cache",
  compression ? "zstd", # one of ["none" "xz" "zstd"]
  rootPaths,
}:

assert lib.elem compression [
  "none"
  "xz"
  "zstd"
];

stdenv.mkDerivation {
  inherit name;

  __structuredAttrs = true;

  exportReferencesGraph.closure = rootPaths;

  preferLocalBuild = true;

  nativeBuildInputs = [
    coreutils
    jq
    python3
    nix
  ]
  ++ lib.optional (compression == "xz") xz
  ++ lib.optional (compression == "zstd") zstd;

  buildCommand = ''
    mkdir -p $out/nar

    python ${./make-binary-cache.py} --compression "${compression}"

    # These directories must exist, or Nix might try to create them in LocalBinaryCacheStore::init(),
    # which fails if mounted read-only
    mkdir $out/realisations
    mkdir $out/debuginfo
    mkdir $out/log
  '';
}