From 1c9d4799c297aa0a2c8292d8d4b97992aa7bdd7d Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Wed, 14 Aug 2024 13:16:44 -0300 Subject: [PATCH] installShellFiles: add new function installBin --- .../in/installShellFiles/setup-hook.sh | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pkgs/by-name/in/installShellFiles/setup-hook.sh b/pkgs/by-name/in/installShellFiles/setup-hook.sh index 4f4e215da4df..f51733e5f11f 100644 --- a/pkgs/by-name/in/installShellFiles/setup-hook.sh +++ b/pkgs/by-name/in/installShellFiles/setup-hook.sh @@ -233,3 +233,27 @@ installShellCompletion() { fi return $retval } + +# installBin [...] +# +# Install each argument to $outputBin +installBin() { + local path + for path in "$@"; do + if (( "${NIX_DEBUG:-0}" >= 1 )); then + echo "installBin: installing $path" + fi + if test -z "$path"; then + echo "installBin: error: path cannot be empty" >&2 + return 1 + fi + local basename + # use stripHash in case it's a nix store path + basename=$(stripHash "$path") + + local outRoot + outRoot=${!outputBin:?} + + install -D --mode=755 --no-target-directory "$path" "${outRoot}/bin/$basename" || return + done +}