nixos-anywhere-example/template/README.md

58 lines
1.7 KiB
Markdown
Raw Normal View History

2023-10-12 13:08:36 +02:00
# nixos-anywhere and disko
2023-10-12 13:04:19 +02:00
2023-10-12 13:08:36 +02:00
This is an example repository for nixos-anywhere and disko.
2023-08-16 15:19:40 +02:00
2023-10-12 13:08:36 +02:00
## Build installer ISO with passwordless SSH
2023-10-12 13:01:44 +02:00
```shell
nix-build '<nixpkgs/nixos>' -A config.system.build.isoImage -I nixos-config=iso.nix
ls result/iso/
```
2023-10-12 13:04:19 +02:00
## Hardware Configuration
2023-08-16 15:19:40 +02:00
2023-10-12 13:04:19 +02:00
Boot the target machine into NixOS live ISO. Then execute the following, ideally while connected via SSH:
2023-08-16 15:19:40 +02:00
2023-10-12 13:04:19 +02:00
```shell
nixos-generate-config --no-filesystems --root /mnt
cat /mnt/etc/nixos/hardware-configuration.nix
2023-08-16 15:19:40 +02:00
```
2023-10-12 13:04:19 +02:00
Save the output to a new file in [./hardware-configs/](./hardware-configs/). In [./flake.nix](./flake.nix) replace `./hardware-configs/yodaHP.nix` with it.
2023-08-16 15:19:40 +02:00
2023-10-12 13:04:19 +02:00
Note: The hardware configuration should not contain any `fileSystems.<name>` options as these are generated based on your disko configuration.
2023-08-16 15:19:40 +02:00
2023-10-12 13:04:19 +02:00
## Installation
2023-08-16 15:19:40 +02:00
2023-10-12 13:04:19 +02:00
To run the interactive vm test run:
2023-08-16 15:19:40 +02:00
2023-10-12 13:04:19 +02:00
```shell
nix --extra-experimental-features nix-command --extra-experimental-features flakes \
run github:numtide/nixos-anywhere -- -f '.#mysystem' --vm-test
```
2023-08-16 15:19:40 +02:00
2023-10-12 13:04:19 +02:00
To install on remote target machine:
2023-08-16 15:19:40 +02:00
2023-10-12 13:04:19 +02:00
```shell
# yodaHP
nix --extra-experimental-features nix-command --extra-experimental-features flakes \
2023-10-12 14:00:14 +02:00
run github:numtide/nixos-anywhere -- --flake '.#mysystem' -p 22 root@192.168.178.106
2023-08-16 15:19:40 +02:00
```
2023-10-16 18:32:46 +02:00
To install on remote target machine **and** print the SSH fingerprint of the new system. If no encrypted disks are set up, the disk password can be left empty:
2023-10-12 13:43:30 +02:00
```shell
# yodaHP
2023-10-16 18:32:46 +02:00
./install-helper.sh 22 root@192.168.178.106
2023-10-12 13:43:30 +02:00
```
2023-10-12 13:04:19 +02:00
## Updating dependencies
2023-08-16 15:19:40 +02:00
2023-10-12 13:04:19 +02:00
Recreate the lock file (i.e. update all inputs) and commit the new lock file:
```shell
nix --extra-experimental-features nix-command --extra-experimental-features flakes \
flake update --commit-lock-file
2023-08-16 15:19:40 +02:00
```