@@ -581,16 +581,19 @@ generateHardwareConfig() {
581
581
mkdir -p " $( dirname " $hardwareConfigPath " ) "
582
582
case " $hardwareConfigBackend " in
583
583
nixos-facter)
584
- if [[ ${isInstaller} == " y" ]]; then
585
- maybeSudo=" "
586
- fi
587
584
if [[ ${hasNixOSFacter} == " n" ]]; then
588
585
step " Generating facter.json using nixos-facter from nixpkgs"
586
+
587
+ # We need to quote all the flags before they get passed to SSH
588
+ # otherwise SSH will drop the quotes which is necessary for
589
+ # `--extra-experimental-features "nix-command flakes"`.
590
+ # We can use the following Bash-ism described at: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Shell-Parameter-Expansion-1
591
+ # For more information: https://unix.stackexchange.com/questions/379181/escape-a-variable-for-use-as-content-of-another-script
589
592
runSshNoTty -o ConnectTimeout=10 \
590
- nix run nixpkgs#nixos-facter " ${nixOptions[@]} " > " $hardwareConfigPath "
593
+ nix shell " ${nixOptions[@]@ Q} " nixpkgs#nixos-facter -c ${maybeSudo} nixos-facter > " $hardwareConfigPath "
591
594
else
592
595
step " Generating facter.json using nixos-facter"
593
- runSshNoTty -o ConnectTimeout=10 " ${maybeSudo} " " nixos-facter" > " $hardwareConfigPath "
596
+ runSshNoTty -o ConnectTimeout=10 ${maybeSudo} nixos-facter > " $hardwareConfigPath "
594
597
fi
595
598
;;
596
599
nixos-generate-config)
@@ -698,6 +701,9 @@ TMPDIR=/root/kexec setsid --wait ${maybeSudo} /root/kexec/kexec/run --kexec-extr
698
701
# After kexec we explicitly set the user to root@
699
702
sshConnection=" root@${sshHost} "
700
703
704
+ # TODO: remove this after we reimport facts post-kexec and set this as a fact
705
+ maybeSudo=" "
706
+
701
707
# waiting for machine to become available again
702
708
until runSsh -o ConnectTimeout=10 -- exit 0; do sleep 5; done
703
709
}
0 commit comments