From fa86b00e2ad992e1a234ea1e5a308c5af45de5c7 Mon Sep 17 00:00:00 2001 From: Nick Novitski Date: Wed, 18 Oct 2023 20:25:06 -0700 Subject: [PATCH] fix: support `--keep` flag in arguments Achieved by consistently using `--ignore-environment` flag, even though that's not strictly necessary. Fixes using devenv, which requires `--keep PATH` to run its shellhook. --- nix-develop-gha.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nix-develop-gha.sh b/nix-develop-gha.sh index 4a3e4b9..e22fce1 100755 --- a/nix-develop-gha.sh +++ b/nix-develop-gha.sh @@ -5,6 +5,10 @@ set -euo pipefail # Read the arguments input into an array, so it can be added to a command line. IFS=" " read -r -a arguments <<<"${INPUT_ARGUMENTS:-}" +with_nix_develop() { + nix develop --ignore-environment "${arguments[@]}" --command "$@" +} + # Add all environment variables except for PATH to GITHUB_ENV. while IFS='=' read -r -d '' n v; do if [ "$n" == "PATH" ]; then @@ -16,10 +20,10 @@ while IFS='=' read -r -d '' n v; do continue fi printf "%s=%s\n" "$n" "$v" >>"${GITHUB_ENV:-/dev/stderr}" -done < <(nix develop --ignore-environment "${arguments[@]}" --command env -0) +done < <(with_nix_develop env -0) # Read the nix environment's $PATH into an array -IFS=":" read -r -a nix_path_array <<<"$(nix develop "${arguments[@]}" --command bash -c "echo \$PATH")" +IFS=":" read -r -a nix_path_array <<<"$(with_nix_develop bash -c "echo \$PATH")" # Iterate over the PATH array in reverse #