○ NixOs
NixOs is a Linux distro based on a fully declarative package manager, Nix. Forget about keeping a script for setting up your system or storing your dotfiles in a repository, Nix will take care of it.
I am currently using NixOs on my server/homelab infrastructure. From my experience so far, it is a step up from Ansible playbooks or similar tools. I am reluctant to switch my main laptops to NixOs, as it's not as easy to program on NixOs as it is to deploy software on it. Hopefully this will change in the future :)
Useful links:
- VimJoyer YouTube channel - high quality Nix tutorials
- Nix-ld - running "normal" binaries on NixOs
- An overview of Nix in practice
- MyNixOs - comfy search engine for NixOs configuration options
- NixOs egui
- Nix Pills
Tips & notes
- NixOS has excellent support for ZFS, arguably the most advanced filesystem currently on the market. Article about ZFS on the unofficial NixOS wiki
- Convert your system configuration into flake-based as soon as possible. It makes your system fully reproducible and makes it easier to use stuff like Agenix
- https://wiki.nixos.org/wiki/Flakes
- Creating and maintaining custom SystemD services/timers is a breeze in NixOS
- https://wiki.nixos.org/wiki/Systemd/User_Services
- There is a
formatter
key in Flake configuration. If you set it to a formatter program, usenix fmt
to format your code
Switching configurations with confidence
My homelab consists of a VPS with a static IP and a server at my place. If I mess something up with the networking configuration (which happened more than I initially thought), I might break the VPN configuration to my homeserver. This would be far from perfect when I'm away from home as I'm unable to log in locally and fix the networking configuration.
I didn't want to install something like Tailscale or
ZeroTier because I'm a purist because it's my
homelab and I wanted to be independent!
The deployment procedure has been working for me for over 2 years and survived multiple configuration mishaps:
- Run
nixos-rebuild build
before you make any modifications - Schedule a reboot in 15 minutes
- Run
nixos-rebuild test
- Run VPN connectivity tests (simple pings via some script or via
ansible
) - Cancel the scheduled reboot
- Run
nixos-rebuild switch