rpi4-nixos-template/README.md
2023-12-20 00:28:10 +01:00

37 lines
1.6 KiB
Markdown

# NixOS template for RPi 4
This template allows to install & manage a NixOS distribution on an RPi4.
## Host Preparation
If the host is not an aarch64-linux machine, it must have nix binfmt configured: `boot.binfmt.emulatedSystems = ["aarch64-linux"];`.
## Initial installation sdcard
There are several things to edit in the `flake.nix` for the installation:
- `"<MY NETWORK>"` & `<PASSWORD>` in [flake.nix](flake.nix)
- `# My SSH Key` in [flake.nix](flake.nix)
You can then generate a sd image using `nix build .#rpi4-install`.
Note that when using binfmt this can take a long time.
The result will be located in `result/sd-image/nixos-sd-image-23.05.20231216.b2566f4-aarch64-linux.img.zst`
It can be written with `sudo zstdcat '.zst' -o /dev/....`.
Tip: to see more details on the build its possible to run `nom build ...` instead of `nix build ...`.
Note that on the first boot there most likely won't be wifi. To enable wifi a `systemctl restart wpa_supplicant` might be needed.
## Deployment of the full configuration
After logging in the rpi4 you need to fetch the system ssh key (located at `/etc/ssh/ssh_host_ed25519_key.pub`) and write it in [secrets.nix](secrets/secrets.nix).
You can then run `nix run .#agenix -- -e wifi.age` in the `secrets` directory to write the wifi key.
The file must be formatted like this:
```
WIFI_KEY="<key>"
```
Then in `config.nix` `<MY NETWORK>` must be substituted with the correct network name, and the SSH key should be filled in.
In `update.sh` the IP must be filled in `HOST`, and then the configuration can be deployed using `update.sh`