mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 15:33:13 +00:00
c8f5c30c37
Derivations affected by this patch set `__structuredAttrs = true;` and provide their own `builder`, i.e. it's necessary to `source .attrs.sh`. Rather than adding even more `if`-`source` monstrums, I decided to modify all of those derivations to use `buildCommand` or `runCommand`, without `builder` being set. Then, `$stdenv/setup` is sourced already and as a result it's safe to assume that `NIX_ATTRS_JSON_FILE`/`NIX_ATTRS_SH_FILE` point to a usable location both in a build and a shell session.
36 lines
877 B
Nix
36 lines
877 B
Nix
{ lib, stdenv, coreutils, jq, python3, nix, xz }:
|
|
|
|
# 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]; }'
|
|
|
|
{ name ? "binary-cache"
|
|
, rootPaths
|
|
}:
|
|
|
|
stdenv.mkDerivation {
|
|
inherit name;
|
|
|
|
__structuredAttrs = true;
|
|
|
|
exportReferencesGraph.closure = rootPaths;
|
|
|
|
preferLocalBuild = true;
|
|
|
|
nativeBuildInputs = [ coreutils jq python3 nix xz ];
|
|
|
|
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
|
|
'';
|
|
}
|