Skip to content

Commit d8d2a47

Browse files
committed
howtos: expand using the nixos installer and fixups for using own kexec image
1 parent e55ffd7 commit d8d2a47

File tree

1 file changed

+78
-20
lines changed

1 file changed

+78
-20
lines changed

docs/howtos.md

Lines changed: 78 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,99 @@
88

99
[Using nixos-anywhere without flakes](#using-nixos-anywhere-without-flakes)
1010

11-
TODO: Add more topics
12-
1311
## Installing on a machine with no operating system
1412

15-
TODO: Still to be documented
13+
If your machine does not run any operating system, you can boot the standard
14+
NixOS installer using a USB or netboot. Detailed instructions on how to do this
15+
can be found in the
16+
[NixOS installation guide](https://nixos.org/manual/nixos/stable/index.html#sec-booting-from-usb).
17+
18+
When you're using `nixos-anywhere`, it will detect a NixOS installer by checking
19+
if the `/etc/os-release` file contains the identifier `VARIANT=installer`
20+
(available since NixOS 23.05). If an installer is detected, `nixos-anywhere`
21+
will not attempt to kexec into its own image. This is particularly useful for
22+
targets that do not have enough RAM for kexec or do not support kexec.
23+
24+
NixOS starts an SSH server on the installer by default, but you need to set a
25+
password in order to access it. To set a password for the `nixos` user, run the
26+
following command in a terminal on the NixOS machine:
27+
28+
```
29+
passwd
30+
```
31+
32+
If you don't know the IP address of the installer on your network, you can find
33+
it by running the following command:
34+
35+
```
36+
$ ip addr
37+
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
38+
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
39+
inet 127.0.0.1/8 scope host lo
40+
valid_lft forever preferred_lft forever
41+
inet6 ::1/128 scope host
42+
valid_lft forever preferred_lft forever
43+
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
44+
link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
45+
altname enp0s3
46+
altname ens3
47+
inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic noprefixroute eth0
48+
valid_lft 86385sec preferred_lft 75585sec
49+
inet6 fec0::5054:ff:fe12:3456/64 scope site dynamic mngtmpaddr noprefixroute
50+
valid_lft 86385sec preferred_lft 14385sec
51+
inet6 fe80::5054:ff:fe12:3456/64 scope link
52+
valid_lft forever preferred_lft forever
53+
```
54+
55+
This will display the IP addresses assigned to your network interface(s),
56+
including the IP address of the installer. In the example output below, the
57+
installer's IP address is `10.0.2.15`, `fec0::5054:ff:fe12:3456`, and
58+
`fe80::5054:ff:fe12:3456%eth0`:
59+
60+
To test if you can connect and your password works, you can use the following
61+
SSH command (replace the IP address with your own):
62+
63+
```
64+
ssh -v nixos@fec0::5054:ff:fe12:3456
65+
```
1666

17-
Include:
67+
You can then use the IP address and other parameters in nixos-anywhere, like
68+
this:
1869

19-
`nixos-anywhere` can detect a nixos installer if it contains the
20-
identifier `VARIANT=installer` in its `/etc/os-release` file. This is the case
21-
for the nixos-unstable installer and will be also part of nixos 23.05. If an
22-
installer is detected `nixos-anywhere` will not try to kexec into its own image.
70+
```
71+
nixos-anywhere --flake '.#' nixos@fec0::5054:ff:fe12:3456
72+
```
2373

2474
## Using your own kexec image
2575

26-
By default `nixos-anywhere` will download the kexec image
27-
from [here](https://github.com/nix-community/nixos-images#kexec-tarballs). It is
28-
also possible to provide your own by using the command line switch `--kexec` to
29-
specify the image file. The image will then be uploaded prior to executing.
76+
By default, nixos-anywhere downloads the kexec image from the off
77+
[NixOS images repository](https://github.com/nix-community/nixos-images#kexec-tarballs).
78+
However, you can provide your own kexec image file if desired. To do this, use
79+
the `--kexec` command line switch followed by the path to your image file. The
80+
image will be uploaded prior to execution.
81+
82+
Here's an example command that demonstrates how to use a custom kexec image with
83+
`nixos-anywhere` for aarch64 instead of the default `x86_64` architecture:
3084

3185
```
3286
nixos-anywhere \
33-
--kexec "$(nix build --print-out-paths github:nix-community/nixos-images#packages.x86_64-linux.kexec-installer-noninteractive-nixos-unstable)/nixos-kexec-installer-noninteractive-x86_64-linux.tar.gz" \
87+
--kexec "$(nix build --print-out-paths github:nix-community/nixos-images#packages.aarch64-linux.kexec-installer-noninteractive-nixos-unstable)/nixos-kexec-installer-noninteractive-aarch64-linux.tar.gz" \
3488
--flake 'github:your-user/your-repo#your-system' \
3589
root@yourip
3690
```
3791

38-
This is particularly useful for distributions like aarch64-linux, where there is
39-
no pre-build image. The following example assumes that your local machine can
40-
build for aarch64-linux either natively or through a remote builder
92+
Make sure to replace `github:your-user/your-repo#your-system` with the
93+
appropriate Flake URL representing your NixOS configuration.
4194

42-
## Using nixos-anywhere without flakes
95+
This is particularly useful for architectures other than `x86_64`, where there
96+
is no pre-build image.
4397

44-
TODO: Add content
45-
46-
```
98+
The example above assumes that your local machine can build for aarch64 either
99+
natively, through a remote builder or by emulating the architecture with qemu
100+
with the following NixOS configuration:
47101

102+
```nix
103+
{
104+
boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
105+
}
48106
```

0 commit comments

Comments
 (0)