NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.07k stars 1.47k forks source link

nix skips the new host SSH prompt when adding a new one to the flake inputs #8048

Open sekunho opened 1 year ago

sekunho commented 1 year ago

Describe the bug

When adding a private repo to the flake's inputs, I expected it to ask me if I want the new host to be added to known hosts. This used to happen but it seems like the last known version is 2.10. Haven't tested it with the minor versions. But from 2.11 onward, this seems to immediately (and seemingly) skip the prompt, doesn't wait, and begins evaluating. Since the user hasn't answered anything, it gets stuck perpetually evaluating. Although I'm able to type yes, it stays stuck I think. It works when I cancel it, and re-run the build.

Steps To Reproduce

Here I'm using nixos-rebuild to demonstrate the problem.

Steps to reproduce the behavior:

  1. Add private repo (in the format git+ssh://git@github.com/foo/bar), that will cause the prompt to show due to it being a new SSH host, to the flake input
  2. nixos-rebuild switch --flake .#<HOST_NAME>
  3. See problem below
sekun@ichi /s/S/dotfiles (main) [1]> nix --version
nix (Nix) 2.11.1
sekun@ichi /s/S/dotfiles (main)> doas nixos-rebuild switch --flake .#ichi
warning: Git tree '/shared/System/dotfiles' is dirty
The authenticity of host 'github.com (20.205.243.166)' can't be established.s."ichi".config.system.build
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names.
evaluating derivation 'git+file:///shared/System/dotfiles#nixosConfigurations."ichi".config.system.buildevaluating derivation 'git+file:///shared/System/dotfiles#nixosConfigurations."ichi".config.system.buildevaluating derivation 'git+file:///shared/System/dotfiles#nixosConfigurations."ichi".config.system.buildevaluating derivation 'git+file:///shared/System/dotfiles#nixosConfigurations."ichi".config.system.build
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
evaluating derivation 'git+file:///shared/System/dotfiles#nixosConfigurations."ichi".config.system.builderror: interrupted by the user

(It reprints evaluating [...] as I type yes)

While it still works, eventually, it's pretty confusing since it hides the possible options; makes it less obvious for the user especially if they're unaware that they even have options to choose from.

Expected behavior

It should wait until the user answers before evaluating

sekun@ichi /s/S/dotfiles (main) [1]> nix --version
nix (Nix) 2.10.3
sekun@ichi /s/S/dotfiles (main)> doas nixos-rebuild switch --flake .#ichi
warning: Git tree '/shared/System/dotfiles' is dirty
The authenticity of host 'github.com (20.205.243.166)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.85, NixOS, 22.11 (Raccoon), 22.11.20230313.67f26c1`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.11.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
balsoft commented 1 year ago

This PR: https://github.com/NixOS/nix/pull/8018 should fix the part where it erases the prompt.