NixOS has been growing rapidly in popularity within the Linux Community, and for good reason. The ability to declare reproducible builds quickly has proven to be immensely useful. NixOS is over 20 years old at this point, and has stood the test of time as an Enterprise-Ready Linux Distro amongst the Debian flavors and RHEL-like Distros.
To that end, I’d like to discuss how I handle NixOS as a system, particularly on enterprise desktops and at scale across a multitude of systems, including TV Menu Displays, POS Systems, and even as Workstation Desktops. Note that my methodology may suit you, or it may not.
Handling .nix Files
To the new user, the idea of handling everything inside a single “Configuration.nix” is enchanting, but the reality is that you as an Administrator will be modularizing your NixOS configurations fast. You need to determine how you want to structure your files, and you need to do it early. Your method will evolve and grow with time, but it is key to determine early what your needs are, and build your nix file structure in accordance with that. I have a few files that I deploy across all machines that have a GUI, regardless of type:
Configuration.nix (My base config, in which everything else is imported)
Console-Tools.nix (My console configuration, setup exactly how I like it)
nix-vim.nix (My text editor configuration, setup exactly how I like it)
Desktop-GUI.nix (My KDE and Wayland Configuration, setup as a base)
There are also some other hardware specific entities as well that are required for certain desktops, particularly ones with Nvidia Graphics cards, along with other random pieces of hardware that deserve their own separate .nix file as a result of their use only amongst specific machines. I import these files directly into configuration.nix and I avoid modifying hardware-configuration.nix unless I absolutely must.