Merge pull request #73712 from virusdave/dnicponski/scratch/add_substitute_nix_support

substitute: init at 0
This commit is contained in:
Timothy DeHerrera 2021-09-11 15:21:40 -06:00 committed by GitHub
commit 0171610faa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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

@ -661,6 +661,8 @@ with pkgs;
srcOnly = callPackage ../build-support/src-only { };
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 { };