about summary refs log tree commit diff
path: root/nixpkgs/pkgs/build-support/substitute/substitute.sh
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/build-support/substitute/substitute.sh')
-rw-r--r--nixpkgs/pkgs/build-support/substitute/substitute.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/build-support/substitute/substitute.sh b/nixpkgs/pkgs/build-support/substitute/substitute.sh
new file mode 100644
index 000000000000..d50a82446639
--- /dev/null
+++ b/nixpkgs/pkgs/build-support/substitute/substitute.sh
@@ -0,0 +1,24 @@
+source $stdenv/setup
+
+args=
+
+target=$out
+if test -n "$dir"; then
+    target=$out/$dir/$name
+    mkdir -p $out/$dir
+fi
+
+substitutionsList=($replacements)
+
+if [[ -v substitutions ]]; then
+    eval "substitutionsList+=($substitutions)"
+fi
+
+substitute $src $target "${substitutionsList[@]}"
+
+if test -n "$isExecutable"; then
+    chmod +x $target
+fi
+
+eval "$postInstall"
+