@@ -481,13 +481,13 @@ runSsh() {
481481}
482482
483483nixCopy () {
484- NIX_SSHOPTS=" ${sshArgs[*]} " nix copy \
484+ NIX_SSHOPTS=" $( printf ' %q ' " $ {sshArgs[@]} " ) " nix copy \
485485 " ${nixOptions[@]} " \
486486 " ${nixCopyOptions[@]} " \
487487 " $@ "
488488}
489489nixBuild () {
490- NIX_SSHOPTS=" ${sshArgs[*]} " nix build \
490+ NIX_SSHOPTS=" $( printf ' %q ' " $ {sshArgs[@]} " ) " nix build \
491491 --print-out-paths \
492492 --no-link \
493493 " ${nixBuildFlags[@]} " \
@@ -567,7 +567,11 @@ uploadSshKey() {
567567importFacts () {
568568 step Gathering machine facts
569569 local facts filteredFacts
570- if ! facts=$( runSsh -o ConnectTimeout=10 enableDebug=$enableDebug sh -- < " $here " /get-facts.sh) ; then
570+ # shellcheck disable=SC2030,SC2031
571+ if ! facts=$(
572+ sshArgs+=(" -o" " ConnectTimeout=10" )
573+ runSsh enableDebug=$enableDebug sh -- < " $here " /get-facts.sh
574+ ) ; then
571575 exit 1
572576 fi
573577 filteredFacts=$( echo " $facts " | grep -E ' ^(has|is|remote)[A-Za-z0-9_]+=\S+' )
@@ -662,16 +666,28 @@ generateHardwareConfig() {
662666 # `--extra-experimental-features "nix-command flakes"`.
663667 # We can use the following Bash-ism described at: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Shell-Parameter-Expansion-1
664668 # For more information: https://unix.stackexchange.com/questions/379181/escape-a-variable-for-use-as-content-of-another-script
665- runSshNoTty -o ConnectTimeout=10 \
666- nix shell " ${nixOptions[@]@ Q} " nixpkgs#nixos-facter -c ${maybeSudo} nixos-facter > " $hardwareConfigPath "
669+ # shellcheck disable=SC2030,SC2031
670+ (
671+ sshArgs+=(" -o" " ConnectTimeout=10" )
672+ runSshNoTty \
673+ nix shell " ${nixOptions[@]@ Q} " nixpkgs#nixos-facter -c ${maybeSudo} nixos-facter
674+ ) > " $hardwareConfigPath "
667675 else
668676 step " Generating facter.json using nixos-facter"
669- runSshNoTty -o ConnectTimeout=10 ${maybeSudo} nixos-facter > " $hardwareConfigPath "
677+ # shellcheck disable=SC2030,SC2031
678+ (
679+ sshArgs+=(" -o" " ConnectTimeout=10" )
680+ runSshNoTty ${maybeSudo} nixos-facter
681+ ) > " $hardwareConfigPath "
670682 fi
671683 ;;
672684 nixos-generate-config)
673685 step " Generating hardware-configuration.nix using nixos-generate-config"
674- runSshNoTty -o ConnectTimeout=10 nixos-generate-config --show-hardware-config --no-filesystems > " $hardwareConfigPath "
686+ # shellcheck disable=SC2030,SC2031
687+ (
688+ sshArgs+=(" -o" " ConnectTimeout=10" )
689+ runSshNoTty nixos-generate-config --show-hardware-config --no-filesystems
690+ ) > " $hardwareConfigPath "
675691 ;;
676692 * )
677693 abort " Unknown hardware config backend: $hardwareConfigBackend "
824840 sshConnection=" root@${sshHost} "
825841
826842 # waiting for machine to become available again
827- until runSsh -o ConnectTimeout=10 -- exit 0; do sleep 5; done
843+ # shellcheck disable=SC2030,SC2031
844+ until (
845+ sshArgs+=(" -o" " ConnectTimeout=10" )
846+ runSsh -- exit 0
847+ ); do sleep 5; done
828848
829849 importFacts
830850
@@ -1010,7 +1030,11 @@ main() {
10101030 # Before we do not have a valid hardware configuration we don't know the machine system
10111031 if [[ ${buildOn} == " auto" ]]; then
10121032 local remoteSystem
1013- remoteSystem=$( runSshNoTty -o ConnectTimeout=10 nix --extra-experimental-features nix-command config show system)
1033+ # shellcheck disable=SC2030,SC2031
1034+ remoteSystem=$(
1035+ sshArgs+=(" -o" " ConnectTimeout=10" )
1036+ runSshNoTty nix --extra-experimental-features nix-command config show system
1037+ )
10141038 checkBuildLocally " ${remoteSystem} "
10151039 # if we cannot figure it out at this point, we will build on the remote host
10161040 if [[ ${buildOn} == " auto" ]]; then
0 commit comments