- Tidied up the wording

- Changed the examples to run nixos-anywhere from Numtide repo rather than expecting it
  to be pre-installed. Alternatively, we could leave it as it was, but provide an installation guide
This commit is contained in:
Jill 2023-05-25 12:14:03 +02:00
parent 19cb3d7d99
commit 3166275d2f

View File

@ -4,6 +4,8 @@
<img title="" src="https://raw.githubusercontent.com/numtide/nixos-anywhere/main/docs/logo.png" alt="" width="129">
[Documentation Index](./INDEX.md)
## Contents
[Installing on a machine with no operating system](#installing-on-a-machine-with-no-operating-system)
@ -14,7 +16,9 @@
## Installing on a machine with no operating system
If your machine doesn't currently have an operating system installed, you still run `nixos-anywhere` remotely to automate the install after booting from the standard NixOS installer. You can either boot from a USB or use `netboot`. The [NixOS installation guide](https://nixos.org/manual/nixos/stable/index.html#sec-booting-from-usb) has detailed instructions on how to boot the installer.
If your machine doesn't currently have an operating system installed, you still run `nixos-anywhere` remotely to automate the install. To do this, you would first need to boot the target machine from the standard NixOS installer. You can either boot from a USB or use `netboot`.
The [NixOS installation guide](https://nixos.org/manual/nixos/stable/index.html#sec-booting-from-usb) has detailed instructions on how to boot the installer.
When you run `nixos-anywhere`, it will determine whether a NixOS installer is present by checking whether the `/etc/os-release` file contains the identifier `VARIANT=installer`. This identifier is available on releases NixOS 23.05 or later.
@ -53,7 +57,7 @@ $ ip addr
This will display the IP addresses assigned to your network interface(s),
including the IP address of the installer. In the example output below, the
installer's IP address is `10.0.2.15`, `fec0::5054:ff:fe12:3456`, and
installer's IP addresses are `10.0.2.15`, `fec0::5054:ff:fe12:3456`, and
`fe80::5054:ff:fe12:3456%eth0`:
To test if you can connect and your password works, you can use the following
@ -63,26 +67,27 @@ SSH command (replace the IP address with your own):
ssh -v nixos@fec0::5054:ff:fe12:3456
```
You can then use the IP address and other parameters in nixos-anywhere, like
this:
You can then use the IP address to run `nixos-anywhere` like this:
```
nixos-anywhere --flake '.#' nixos@fec0::5054:ff:fe12:3456
nix run github:numtide/nixos-anywhere -- --flake '.#myconfig' nixos@fec0::5054:ff:fe12:3456
```
This example assumes a flake in the curent directory containing a configuration named `myconfig`.
## Using your own kexec image
By default, nixos-anywhere downloads the kexec image from the off
[NixOS images repository](https://github.com/nix-community/nixos-images#kexec-tarballs).
However, you can provide your own kexec image file if desired. To do this, use
the `--kexec` command line switch followed by the path to your image file. The
image will be uploaded prior to execution.
By default, `nixos-anywhere` downloads the kexec image from the [NixOS images repository](https://github.com/nix-community/nixos-images#kexec-tarballs).
Here's an example command that demonstrates how to use a custom kexec image with
`nixos-anywhere` for aarch64 instead of the default `x86_64` architecture:
However, you can provide your own `kexec` image file if you need to use a different one. This is particularly useful for architectures other than `x86_64`, since they don't have a pre-build image.
To do this, use the `--kexec` command line switch followed by the path to your image file. The image will be uploaded prior to execution.
Here's an example command that demonstrates how to use a custom kexec image with `nixos-anywhere` for aarch64 instead of the default `x86_64` architecture:
```
nixos-anywhere \
nix run github:numtide/nixos-anywhere -- \
--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" \
--flake 'github:your-user/your-repo#your-system' \
root@yourip
@ -91,12 +96,15 @@ nixos-anywhere \
Make sure to replace `github:your-user/your-repo#your-system` with the
appropriate Flake URL representing your NixOS configuration.
This is particularly useful for architectures other than `x86_64`, where there
is no pre-build image.
The example above assumes that your local machine can build for aarch64 either
natively, through a remote builder or by emulating the architecture with qemu
with the following NixOS configuration:
The example above assumes that your local machine can build for aarch64 in one of the following ways:
- Natively
- Through a remote builder
- By emulating the architecture with qemu using the following NixOS configuration:
```nix
{