From 3702177b4e5364d552a85284b446d068aef92f41 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Fri, 18 Oct 2024 18:57:51 +0200 Subject: [PATCH] nixos/test-instrumentation: fix shellcheck findings with enableStrictShellChecks enabled Signed-off-by: Sefa Eyeoglu --- nixos/modules/testing/test-instrumentation.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix index 050c817e8718ab..0777a01dff7cd9 100644 --- a/nixos/modules/testing/test-instrumentation.nix +++ b/nixos/modules/testing/test-instrumentation.nix @@ -19,8 +19,19 @@ let export HOME=/root export DISPLAY=:0.0 + # Determine if this script is ran with nounset + STRICT="false" + if set -o | grep --quiet --perl-regexp "nounset\s+on"; then + STRICT="true" + fi + if [[ -e /etc/profile ]]; then + # TODO: Currently shell profiles are not checked at build time, + # so we need to unset stricter options to source them + set +o nounset + # shellcheck disable=SC1091 source /etc/profile + [ "$STRICT" = "true" ] && set -o nounset fi # Don't use a pager when executing backdoor @@ -45,7 +56,7 @@ let # we can also run non-NixOS guests during tests. This, however, is # mostly futureproofing as the test instrumentation is still very # tightly coupled to NixOS. - PS1= exec ${pkgs.coreutils}/bin/env bash --norc /dev/hvc0 + PS1="" exec ${pkgs.coreutils}/bin/env bash --norc /dev/hvc0 ''; serviceConfig.KillSignal = "SIGHUP"; };