This will generate a script which calls all deployment script as described in the section [...deploy a configuration change to production](#deploy-a-configuration-change-to-production).
This will generate a script which calls all deployment script as described in the section [...deploy a configuration change to production](#deploy-a-configuration-change-to-production).
### ...unlock a virtual machine with full disk encryption
### ...unlock a machine with full disk encryption
**NOTE: These instructions are a work in progress**
```
```
nix-build -A unlock.HOSTNAME && ./result
nix-build -A unlock.HOSTNAME && ./result
...
@@ -129,7 +128,7 @@ Alternatively, use the [official ISO](https://nixos.org/download.html).
...
@@ -129,7 +128,7 @@ Alternatively, use the [official ISO](https://nixos.org/download.html).
nix build -f . isoImage
nix build -f . isoImage
```
```
Afterwards, extract the resulting .tar.xz to `/` on the target host and execute `./kexec_nixos`.
Afterwards, extract the resulting .tar.xz to `/` on the target host and execute `./kexec_nixos`. This will jump to the new kernel via the [kexec(8)](https://man7.org/linux/man-pages/man8/kexec.8.html) syscall.
### ...add a new server to the configuration
### ...add a new server to the configuration
...
@@ -139,12 +138,12 @@ Create a new directory with the hostname under `hosts/` and copy the configurati
...
@@ -139,12 +138,12 @@ Create a new directory with the hostname under `hosts/` and copy the configurati
## Nix caveats and how we solve them
## Nix caveats and how we solve them
* Nix can not manage state
- Nix can not manage state
* Create backups of stateful data (databases, etc.) to ensure rollbacks are always possible
- Create backups of stateful data (databases, etc.) to ensure rollbacks are always possible
* Nix can not manage secrets, because all files in the nix store are world-readable
- Nix can not manage secrets, because all files in the nix store are world-readable
* Deploy secrets to /var/src/secrets/ from local password-store
- Deploy secrets to /var/src/secrets/ from local password-store
* Services read the secrets they need from there at runtime
- Services read the secrets they need from there at runtime
* Services that don't support reading the secret from a file use a ExecStartPre script to template secrets into the configuration file
- Services that don't support reading the secret from a file use a ExecStartPre script to template secrets into the configuration file
## Things to note when working on NixOS systems
## Things to note when working on NixOS systems
...
@@ -152,7 +151,7 @@ Create a new directory with the hostname under `hosts/` and copy the configurati
...
@@ -152,7 +151,7 @@ Create a new directory with the hostname under `hosts/` and copy the configurati
- Instead of creating users with `useradd`, add them to the NixOS system configuration (in [](common/users.nix)
- Instead of creating users with `useradd`, add them to the NixOS system configuration (in [](common/users.nix)
- Don't touch files in /etc/! They are automatically generated. If you want to change an option, look for the corresponding NixOS module option on [nixos.org/nixos/options.html](https://nixos.org/nixos/options.html)
- Don't touch files in /etc/! They are automatically generated. If you want to change an option, look for the corresponding NixOS module option on [nixos.org/nixos/options.html](https://nixos.org/nixos/options.html)
- If you want use an application that is not available on the system:
- If you want use an application that is not available on the system:
- Use the package search on [nixos.org/nixos/packages.html](https://nixos.org/nixos/packages.html?channel=nixpkgs-unstable) to find the application's **Attribute name**
- Use the package search on [nixos.org/nixos/packages.html](https://nixos.org/nixos/packages.html?channel=nixpkgs-unstable) to find the application's **attribute name**
- Use nix-shell, for example: `nix-shell -p tcpdump --run "tcpdump -i enp4s0"`
- Use nix-shell, for example: `nix-shell -p tcpdump --run "tcpdump -i enp4s0"`
- If you use an application a lot, consider adding it to the [list here](common/default.nix)
- If you use an application a lot, consider adding it to the [list here](common/default.nix)
- Avoid nix-env, because it will install applications into your user profile and these won't be updated with the system configuration.
- Avoid nix-env, because it will install applications into your user profile and these won't be updated with the system configuration.