mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-24 07:53:19 +00:00
Merge pull request #73712 from virusdave/dnicponski/scratch/add_substitute_nix_support
substitute: init at 0
This commit is contained in:
commit
0171610faa
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"
|
||||||
|
|
@ -661,6 +661,8 @@ with pkgs;
|
|||||||
|
|
||||||
srcOnly = callPackage ../build-support/src-only { };
|
srcOnly = callPackage ../build-support/src-only { };
|
||||||
|
|
||||||
|
substitute = callPackage ../build-support/substitute/substitute.nix { };
|
||||||
|
|
||||||
substituteAll = callPackage ../build-support/substitute/substitute-all.nix { };
|
substituteAll = callPackage ../build-support/substitute/substitute-all.nix { };
|
||||||
|
|
||||||
substituteAllFiles = callPackage ../build-support/substitute-files/substitute-all-files.nix { };
|
substituteAllFiles = callPackage ../build-support/substitute-files/substitute-all-files.nix { };
|
||||||
|
Loading…
Reference in New Issue
Block a user