Skip to content

Commit 24f2d37

Browse files
sedlundmergify[bot]
authored andcommitted
fix(nixos-generate-config): dont redirect carriage returns in output files
1 parent 6d1c786 commit 24f2d37

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/nixos-anywhere.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Options:
7373
Also supports variants:
7474
nixos-anywhere --flake .#nixosConfigurations.mymachine.config.virtualisation.vmVariant
7575
* --target-host <ssh-host>
76-
specified the SSH target host to deploy onto.
76+
set the SSH target host to deploy onto.
7777
* -i <identity_file>
7878
selects which SSH private key file to use.
7979
* -p, --ssh-port <ssh_port>
@@ -333,6 +333,9 @@ parseArgs() {
333333
}
334334

335335
# ssh wrapper
336+
runSshNoTty() {
337+
ssh -i "$sshKeyDir"/nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "${sshArgs[@]}" "$sshConnection" "$@"
338+
}
336339
runSshTimeout() {
337340
timeout 10 ssh -i "$sshKeyDir"/nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "${sshArgs[@]}" "$sshConnection" "$@"
338341
}
@@ -449,19 +452,18 @@ generateHardwareConfig() {
449452
nixos-facter)
450453
if [[ ${isInstaller} == "y" ]]; then
451454
if [[ ${hasNixOSFacter} == "n" ]]; then
452-
abort "nixos-facter is not available in booted installer. You may want to boot an installer image from here instead: https://github.com/nix-community/nixos-images"
455+
abort "nixos-facter is not available in booted installer, use nixos-generate-config. For nixos-facter, you may want to boot an installer image from here instead: https://github.com/nix-community/nixos-images"
453456
fi
454457
else
455458
maybeSudo=""
456459
fi
457460

458461
step "Generating hardware-configuration.nix using nixos-facter"
459-
# FIXME: if we take the output directly it adds some weird characters at the beginning
460-
runSsh -o ConnectTimeout=10 ${maybeSudo} "nixos-facter" >"$hardwareConfigPath"
462+
runSshNoTty -o ConnectTimeout=10 ${maybeSudo} "nixos-facter" >"$hardwareConfigPath"
461463
;;
462464
nixos-generate-config)
463465
step "Generating hardware-configuration.nix using nixos-generate-config"
464-
runSsh -o ConnectTimeout=10 nixos-generate-config --show-hardware-config --no-filesystems >"$hardwareConfigPath"
466+
runSshNoTty -o ConnectTimeout=10 nixos-generate-config --show-hardware-config --no-filesystems >"$hardwareConfigPath"
465467
;;
466468
*)
467469
abort "Unknown hardware config backend: $hardwareConfigBackend"

0 commit comments

Comments
 (0)