mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-10 16:45:51 +03: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:
parent
a6934e3653
commit
7914de9b8c
14
pkgs/build-support/substitute/substitute.nix
Normal file
14
pkgs/build-support/substitute/substitute.nix
Normal 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; })
|
18
pkgs/build-support/substitute/substitute.sh
Normal file
18
pkgs/build-support/substitute/substitute.sh
Normal 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"
|
||||
|
@ -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 { };
|
||||
|
Loading…
Reference in New Issue
Block a user