2020-09-23 10:36:46 +02:00
|
|
|
# felschr's NixOS configuration
|
2019-08-24 13:12:32 +02:00
|
|
|
|
2020-09-23 10:36:46 +02:00
|
|
|
## Installation
|
|
|
|
|
2022-02-11 00:45:24 +01:00
|
|
|
Clone the configuration into `/etc/nixos`.
|
2020-09-23 10:36:46 +02:00
|
|
|
|
|
|
|
On a new machine run:
|
|
|
|
|
|
|
|
```sh
|
2021-01-29 01:25:41 +01:00
|
|
|
scripts/setup-partitions
|
2019-08-24 13:12:32 +02:00
|
|
|
```
|
2020-09-23 10:36:46 +02:00
|
|
|
|
2022-08-25 22:20:42 +02:00
|
|
|
Then move the resulting `/mnt/etc/nixos/hardware-configuration.nix` to `./hardware/<config>.nix`.
|
2022-02-11 00:45:24 +01:00
|
|
|
Update the configuration according to the script output, if necessary. Btrfs mount options likely need to be added, for example.
|
2022-08-25 22:20:42 +02:00
|
|
|
Copy the configuration from `/etc/nixos` to `/mnt/etc/nixos`.
|
2022-02-11 00:45:24 +01:00
|
|
|
|
|
|
|
Reference this hardware config in a `nixosConfigurations.<config>` section in `flake.nix`.
|
2020-09-23 10:36:46 +02:00
|
|
|
|
2022-10-04 11:10:30 +02:00
|
|
|
Now set up a device key that will be used by agenix.
|
|
|
|
Create a new key and re-encrypt the secrets on an existing device & pull the changes.
|
|
|
|
To create a new key run:
|
|
|
|
```sh
|
|
|
|
mkdir -p /mnt/etc/secrets/initrd
|
|
|
|
ssh-keygen -t ed25519 -N "" -f /mnt/etc/secrets/initrd/ssh_host_ed25519_key
|
|
|
|
```
|
|
|
|
|
|
|
|
You will likely need to temporarily set `age.identityPaths` for the installation to succeed:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
age.identityPaths = "/etc/secrets/initrd/ssh_host_ed25519_key";
|
|
|
|
```
|
|
|
|
|
2020-09-23 10:36:46 +02:00
|
|
|
To install run the following command where `<config>` matches `outputs.nixosConfigurations.<config>` in `flake.nix`:
|
|
|
|
|
|
|
|
```sh
|
2022-08-25 22:20:42 +02:00
|
|
|
nixos-install --flake '/mnt/etc/nixos#<config>'
|
|
|
|
```
|
|
|
|
|
|
|
|
After the installation finished, set a password for the user:
|
|
|
|
```
|
|
|
|
passwd <user>
|
2020-09-23 10:36:46 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Updating
|
|
|
|
|
2022-02-11 00:45:24 +01:00
|
|
|
Update all flake inputs:
|
2020-09-23 10:36:46 +02:00
|
|
|
|
|
|
|
```sh
|
|
|
|
nix flake update
|
2022-02-11 00:45:24 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
Update a specific flake input:
|
|
|
|
|
|
|
|
```
|
|
|
|
nix flake lock --update-input <input>
|
2020-09-23 10:36:46 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Rebuilding the system
|
|
|
|
|
|
|
|
Rebuild the system:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
sudo nixos-rebuild switch
|
|
|
|
```
|
|
|
|
|
2022-02-11 00:45:24 +01:00
|
|
|
Rebuild the system for a remote machine:
|
2020-09-23 10:36:46 +02:00
|
|
|
|
|
|
|
```sh
|
2022-02-11 00:45:24 +01:00
|
|
|
sudo nixos-rebuild switch --flake '/etc/nixos#<config>' --target-host user@hostname --use-remote-sudo
|
2022-10-04 11:10:30 +02:00
|
|
|
```
|