Skip to content

Commit 2a1b148

Browse files
committed
nixos-anywhere: fix quoting for nix run nixpkgs#nixos-facter over SSH
1 parent 9e8eb99 commit 2a1b148

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/nixos-anywhere.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -586,9 +586,14 @@ generateHardwareConfig() {
586586
fi
587587
if [[ ${hasNixOSFacter} == "n" ]]; then
588588
step "Generating facter.json using nixos-facter from nixpkgs"
589-
runSshNoTty -o ConnectTimeout=10 ${maybeSudo} \
590-
nix run "${nixOptions[@]}" \
591-
nixpkgs#nixos-facter >"$hardwareConfigPath"
589+
590+
# We need to quote all the flags before they get passed to SSH
591+
# otherwise SSH will drop the quotes which is necessary for
592+
# `--extra-experimental-features "nix-command flakes"`.
593+
# We can use the following Bash-ism described at: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Shell-Parameter-Expansion-1
594+
# For more information: https://unix.stackexchange.com/questions/379181/escape-a-variable-for-use-as-content-of-another-script
595+
runSshNoTty -o ConnectTimeout=10 \
596+
nix shell "${nixOptions[@]@Q}" nixpkgs#nixos-facter -c ${maybeSudo} nixos-facter >"$hardwareConfigPath"
592597
else
593598
step "Generating facter.json using nixos-facter"
594599
runSshNoTty -o ConnectTimeout=10 ${maybeSudo} nixos-facter >"$hardwareConfigPath"

0 commit comments

Comments
 (0)