lol

substitute: init at 0

Similar to the colocated `substituteAll` script and derivation, this
PR adds nix-level support for `substitute` directly. This is useful,
for instance, to be able to easily make tweaks to patch files for an
existing derivation's existing patch files.

+34
+14
pkgs/build-support/substitute/substitute.nix
··· 1 + { stdenvNoCC }: 2 + 3 + args: 4 + 5 + # This is a wrapper around `substitute` in the stdenv. 6 + # The `replacements` attribute should be a list of list of arguments 7 + # to `substitute`, such as `[ "--replace" "sourcetext" "replacementtext" ]` 8 + stdenvNoCC.mkDerivation ({ 9 + name = if args ? name then args.name else baseNameOf (toString args.src); 10 + builder = ./substitute.sh; 11 + inherit (args) src; 12 + preferLocalBuild = true; 13 + allowSubstitutes = false; 14 + } // args // { replacements = args.replacements; })
+18
pkgs/build-support/substitute/substitute.sh
··· 1 + source $stdenv/setup 2 + 3 + args= 4 + 5 + target=$out 6 + if test -n "$dir"; then 7 + target=$out/$dir/$name 8 + mkdir -p $out/$dir 9 + fi 10 + 11 + substitute $src $target $replacements 12 + 13 + if test -n "$isExecutable"; then 14 + chmod +x $target 15 + fi 16 + 17 + eval "$postInstall" 18 +
+2
pkgs/top-level/all-packages.nix
··· 420 420 421 421 srcOnly = args: callPackage ../build-support/src-only args; 422 422 423 + substitute = callPackage ../build-support/substitute/substitute.nix { }; 424 + 423 425 substituteAll = callPackage ../build-support/substitute/substitute-all.nix { }; 424 426 425 427 substituteAllFiles = callPackage ../build-support/substitute-files/substitute-all-files.nix { };