@@ -18,15 +18,41 @@ If an installer is detected, `nixos-anywhere` will not attempt to `kexec` into
1818its own image. This is particularly useful for targets that don't have enough
1919RAM for ` kexec ` or don't support ` kexec ` .
2020
21+ Often you will need some kind of network connectivity before installing NixOS.
22+ Use the live system to connect to some network.
23+
2124NixOS starts an SSH server on the installer by default, but you need to set a
2225password in order to access it. To set a password for the ` nixos ` user, run the
2326following command in a terminal on the NixOS machine:
2427
25- ```
28+ ``` shell
2629passwd
2730```
2831
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
3056it by running the following command:
3157
3258```
@@ -57,15 +83,15 @@ installer's IP addresses are `10.0.2.15`, `fec0::5054:ff:fe12:3456`, and
5783To test if you can connect and your password works, you can use the following
5884SSH command (replace the IP address with your own):
5985
60- ```
86+ ``` shell
6187ssh -v nixos@fec0::5054:ff:fe12:3456
6288```
6389
6490You can then use the IP address to run ` nixos-anywhere ` like this:
6591
66- ```
92+ ``` shell
6793nix run github:nix-community/nixos-anywhere -- --flake ' .#myconfig' --target-host nixos@fec0::5054:ff:fe12:3456
6894```
6995
7096This example assumes a flake in the current directory containing a configuration
71- named ` myconfig ` .
97+ named ` myconfig ` .
0 commit comments