at 24.11-pre 35 lines 877 B view raw
1{ lib, stdenv, coreutils, jq, python3, nix, xz }: 2 3# This function is for creating a flat-file binary cache, i.e. the kind created by 4# nix copy --to file:///some/path and usable as a substituter (with the file:// prefix). 5 6# For example, in the Nixpkgs repo: 7# nix-build -E 'with import ./. {}; mkBinaryCache { rootPaths = [hello]; }' 8 9{ name ? "binary-cache" 10, rootPaths 11}: 12 13stdenv.mkDerivation { 14 inherit name; 15 16 __structuredAttrs = true; 17 18 exportReferencesGraph.closure = rootPaths; 19 20 preferLocalBuild = true; 21 22 nativeBuildInputs = [ coreutils jq python3 nix xz ]; 23 24 buildCommand = '' 25 mkdir -p $out/nar 26 27 python ${./make-binary-cache.py} 28 29 # These directories must exist, or Nix might try to create them in LocalBinaryCacheStore::init(), 30 # which fails if mounted read-only 31 mkdir $out/realisations 32 mkdir $out/debuginfo 33 mkdir $out/log 34 ''; 35}