Maintenance and Troubleshooting
The administrator’s daily routine: keeping the fleet clean, intervening on a host, rolling back after a bad configuration, reading logs.
Acting on a host
Section titled “Acting on a host”All these commands target a host (or a pattern / list) via colmena:
| Command | Effect |
|---|---|
just enter <host> | Open an SSH shell (alias e) |
just reboot <host> | Reboot |
just halt <host> | Shutdown |
just gc <host> | Purge generations + clean the store |
just fix-boot <host> | Reinstall the boot loader |
Clean and format code
Section titled “Clean and format code”Before committing or deploying, normalize the repository:
just clean # fix + check + generate + formatjust check-all: unit tests + flake checking (before deployment).just gc <host>: reclaim disk space (deletes old generations).
Rollback
Section titled “Rollback”Each deployment creates a NixOS generation. In case of issues:
-
At boot : choose a previous generation from the boot menu.
-
Live rollback : revert to the previous generation then make it active:
Fenêtre de terminal just enter <host>sudo nixos-rebuild switch --rollback -
Through code :
git revertthe faulty configuration, then redeploy:Fenêtre de terminal just apply <host>
Reading logs
Section titled “Reading logs”just enter <host>journalctl -u <service> -n 100 --no-pager # logs d'un servicejournalctl -p err -b # erreurs depuis le démarragesystemctl status <service> # état d'une unité