@@ -18,15 +18,41 @@ If an installer is detected, `nixos-anywhere` will not attempt to `kexec` into
18
18
its own image. This is particularly useful for targets that don't have enough
19
19
RAM for ` kexec ` or don't support ` kexec ` .
20
20
21
+ Often you will need some kind of network connectivity before installing NixOS.
22
+ Use the live system to connect to some network.
23
+
21
24
NixOS starts an SSH server on the installer by default, but you need to set a
22
25
password in order to access it. To set a password for the ` nixos ` user, run the
23
26
following command in a terminal on the NixOS machine:
24
27
25
- ```
28
+ ``` shell
26
29
passwd
27
30
```
28
31
29
- If you don't know the IP address of the installer on your network, you can find
32
+ ## Local installation
33
+
34
+ If your source and target machines are the same (the one booted from USB), you
35
+ can install NixOS by running ` nixos-anywhere ` like this:
36
+
37
+ ``` shell
38
+ # Set your flake URL
39
+ flake=' github:nix-community/nixos-anywhere-examples#generic'
40
+
41
+ # Install it
42
+ nix --extra-experimental-features ' nix-command flakes' run github:nix-community/nixos-anywhere -- --flake " $flake " --target-host nixos@localhost --build-on remote
43
+ ```
44
+
45
+ In this kind of installation, the flag ` --build-on remote ` makes sure the build
46
+ is done after partitioning and mounting ` /nix ` . Otherwise, it would be prebuilt
47
+ in the live system, which could then run out of space quickly.
48
+
49
+ ## Remote installation
50
+
51
+ If your source and target machines are different (for example, you want to
52
+ install a new laptop, but the flake is in another laptop), both will have to
53
+ connect. This is commonly done by connecting both to the same local network.
54
+
55
+ If you don't know the IP address of the target machine on your network, you can find
30
56
it by running the following command:
31
57
32
58
```
@@ -57,15 +83,15 @@ installer's IP addresses are `10.0.2.15`, `fec0::5054:ff:fe12:3456`, and
57
83
To test if you can connect and your password works, you can use the following
58
84
SSH command (replace the IP address with your own):
59
85
60
- ```
86
+ ``` shell
61
87
ssh -v nixos@fec0::5054:ff:fe12:3456
62
88
```
63
89
64
90
You can then use the IP address to run ` nixos-anywhere ` like this:
65
91
66
- ```
92
+ ``` shell
67
93
nix run github:nix-community/nixos-anywhere -- --flake ' .#myconfig' --target-host nixos@fec0::5054:ff:fe12:3456
68
94
```
69
95
70
96
This example assumes a flake in the current directory containing a configuration
71
- named ` myconfig ` .
97
+ named ` myconfig ` .
0 commit comments