2024-06-30 08:12:46 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
coreutils,
|
|
|
|
jq,
|
|
|
|
python3,
|
|
|
|
nix,
|
|
|
|
xz,
|
|
|
|
}:
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
# This function is for creating a flat-file binary cache, i.e. the kind created by
|
|
|
|
# nix copy --to file:///some/path and usable as a substituter (with the file:// prefix).
|
|
|
|
|
|
|
|
# For example, in the Nixpkgs repo:
|
|
|
|
# nix-build -E 'with import ./. {}; mkBinaryCache { rootPaths = [hello]; }'
|
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
{
|
|
|
|
name ? "binary-cache",
|
|
|
|
rootPaths,
|
2024-05-02 00:46:19 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
inherit name;
|
|
|
|
|
|
|
|
__structuredAttrs = true;
|
|
|
|
|
|
|
|
exportReferencesGraph.closure = rootPaths;
|
|
|
|
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
coreutils
|
|
|
|
jq
|
|
|
|
python3
|
|
|
|
nix
|
|
|
|
xz
|
|
|
|
];
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/nar
|
|
|
|
|
|
|
|
python ${./make-binary-cache.py}
|
|
|
|
|
|
|
|
# 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
|
|
|
|
'';
|
|
|
|
}
|