File tree Expand file tree Collapse file tree 4 files changed +63
-3
lines changed Expand file tree Collapse file tree 4 files changed +63
-3
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,9 @@ example uses a local directory on the source machine.
113
113
If your SSH key is not found, you will be asked for your password. If you are
114
114
using a non-root user, you must have access to sudo without a password. To avoid
115
115
SSH password prompts, set the ` SSHPASS ` environment variable to your password
116
- and add ` --env-password ` to the ` nixos-anywhere ` command.
116
+ and add ` --env-password ` to the ` nixos-anywhere ` command. If providing a
117
+ specific SSH key through ` -i ` (identity_file), this key will then be used for
118
+ the installation and no temporary SSH key will be created.
117
119
118
120
### 7. (Optional) Test your NixOS and Disko configuration
119
121
Original file line number Diff line number Diff line change @@ -385,10 +385,15 @@ runVmTest() {
385
385
}
386
386
387
387
uploadSshKey () {
388
- # we generate a temporary ssh keypair that we can use during nixos-anywhere
389
388
# ssh-copy-id requires this directory
390
389
mkdir -p " $HOME /.ssh/"
391
- ssh-keygen -t ed25519 -f " $sshKeyDir " /nixos-anywhere -P " " -C " nixos-anywhere" > /dev/null
390
+ if [[ -n ${sshPrivateKeyFile} ]]; then
391
+ cp " $sshPrivateKeyFile " " $sshKeyDir /nixos-anywhere"
392
+ ssh-keygen -y -f " $sshKeyDir /nixos-anywhere" > " $sshKeyDir /nixos-anywhere.pub"
393
+ else
394
+ # we generate a temporary ssh keypair that we can use during nixos-anywhere
395
+ ssh-keygen -t ed25519 -f " $sshKeyDir " /nixos-anywhere -P " " -C " nixos-anywhere" > /dev/null
396
+ fi
392
397
393
398
declare -a sshCopyIdArgs
394
399
if [[ -n ${sshPrivateKeyFile} ]]; then
Original file line number Diff line number Diff line change 20
20
from-nixos-with-sudo-stable = import ./from-nixos-with-sudo.nix testInputsStable ;
21
21
from-nixos-with-generated-config = import ./from-nixos-generate-config.nix testInputsUnstable ;
22
22
from-nixos-build-on-remote = import ./from-nixos-build-on-remote.nix testInputsUnstable ;
23
+ from-nixos-separated-phases = import ./from-nixos-separated-phases.nix testInputsUnstable ;
23
24
} ) ;
24
25
}
Original file line number Diff line number Diff line change
1
+ ( import ./lib/test-base.nix ) {
2
+ name = "from-nixos-separated-phases" ;
3
+ nodes = {
4
+ installer = ./modules/installer.nix ;
5
+ installed = {
6
+ services . openssh . enable = true ;
7
+ virtualisation . memorySize = 1024 ;
8
+
9
+ users . users . nixos = {
10
+ isNormalUser = true ;
11
+ openssh . authorizedKeys . keyFiles = [ ./modules/ssh-keys/ssh.pub ] ;
12
+ extraGroups = [ "wheel" ] ;
13
+ } ;
14
+ security . sudo . enable = true ;
15
+ security . sudo . wheelNeedsPassword = false ;
16
+ } ;
17
+ } ;
18
+ testScript = ''
19
+ start_all()
20
+
21
+ with subtest("Kexec Phase"):
22
+ installer.succeed("""
23
+ nixos-anywhere \
24
+ -i /root/.ssh/install_key \
25
+ --debug \
26
+ --kexec /etc/nixos-anywhere/kexec-installer \
27
+ --phases kexec \
28
+ --store-paths /etc/nixos-anywhere/disko /etc/nixos-anywhere/system-to-install \
29
+ nixos@installed >&2
30
+ """)
31
+
32
+ with subtest("Disko Phase"):
33
+ output = installer.succeed("""
34
+ nixos-anywhere \
35
+ -i /root/.ssh/install_key \
36
+ --debug \
37
+ --phases disko \
38
+ --store-paths /etc/nixos-anywhere/disko /etc/nixos-anywhere/system-to-install \
39
+ installed >&2
40
+ """)
41
+
42
+ with subtest("Install Phase"):
43
+ installer.succeed("""
44
+ nixos-anywhere \
45
+ -i /root/.ssh/install_key \
46
+ --debug \
47
+ --phases install \
48
+ --store-paths /etc/nixos-anywhere/disko /etc/nixos-anywhere/system-to-install \
49
+ root@installed >&2
50
+ """)
51
+ '' ;
52
+ }
You can’t perform that action at this time.
0 commit comments