As someone who started their Nix journey around the end of 2022, most of my experience has been with Flakes. I enjoy them a lot, but as I’ve learned more about them and Nix in general, it has made me curious to explore alternatives and how things were done before they became so prominent in the community
I’ve already found most common practices, like default.nix
files containing a top-level package set (and maybe some other stuff from time to time), release.nix
describing CI-ish jobs and evaluating things on a per-system basis – rather than the more imperative { pkgs ? import <nixpkgs> { } }
found in a default.nix
– and of course the still pretty common shell.nix
. When it comes to configurations though, it appears to be much more unclear
From what I have gathered, tools like NixOps, Morph, etc. were some common choices for this kind of thing. They feel a bit like overkill for a handful of local machines though (such as a desktop and laptop), and AFAICT local deployment support is iffy outside of more modern solutions like Colmena
Another method I’ve seen somewhat often is simply setting nixos-config
in NIX_PATH. I remember seeing this a bit before I switched to Flakes, and it’s how I’ve mostly assumed this would work, with development shell hooks emulating behavior similar to nixos-rebuild
:
mkShellNoCC {
shellHook = ''
export NIX_PATH="nixos-config=${./configurations}/$(cat /etc/hostname):${NIX_PATH:-}"
'';
}
Lastly, as of 24.11, nixos-rebuild
supports the --file
and --attr
flags. I haven’t been able to find much usage of this yet, but it seems like a pretty nice alternative to both of the above, and a lot closer to the (IMO) better UX Flakes users have in this situation. Not really sure what the best way to organize configurations for these flags would be though – maybe a configurations.nix?
Anyways: how far off the mark am I with this bit of NixOS history? Were env var manipulation and deployment tools really the best approaches to managing multiple configurations pre-Flakes? Was it not as bad as I think? How did you handle these things years ago?
Thanks for any answers in advance