1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-22 21:50:55 +00:00

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.
This commit is contained in:
Dave Nicponski 2019-11-18 15:48:04 -05:00
parent a6934e3653
commit 7914de9b8c
3 changed files with 34 additions and 0 deletions

View file

@ -0,0 +1,14 @@
{ stdenvNoCC }:
args:
# This is a wrapper around `substitute` in the stdenv.
# The `replacements` attribute should be a list of list of arguments
# to `substitute`, such as `[ "--replace" "sourcetext" "replacementtext" ]`
stdenvNoCC.mkDerivation ({
name = if args ? name then args.name else baseNameOf (toString args.src);
builder = ./substitute.sh;
inherit (args) src;
preferLocalBuild = true;
allowSubstitutes = false;
} // args // { replacements = args.replacements; })

View file

@ -0,0 +1,18 @@
source $stdenv/setup
args=
target=$out
if test -n "$dir"; then
target=$out/$dir/$name
mkdir -p $out/$dir
fi
substitute $src $target $replacements
if test -n "$isExecutable"; then
chmod +x $target
fi
eval "$postInstall"

View file

@ -420,6 +420,8 @@ in
srcOnly = args: callPackage ../build-support/src-only args;
substitute = callPackage ../build-support/substitute/substitute.nix { };
substituteAll = callPackage ../build-support/substitute/substitute-all.nix { };
substituteAllFiles = callPackage ../build-support/substitute-files/substitute-all-files.nix { };