I switched to the flake-based NixOS configuration on my laptop for more than two years. It works as well as the channel-based setup, with two additional benefits:
-
It’s reproducible and updatable. In the flake-based setup, all the input revisions (channel revisiots) are recorded inside a text file
flake.lockin the flake-based setup. You could bringflake.nix,flake.lockand other configuration files to another computer and set them up with exactly the same version of everything. You could update input-by-input withnix flake lock --update-input inputname, or update all the inputs bynix flake updatewithout manually changing the hashes.In contrast, the only way to ensure reproducibility for the channel-based setup when setting up on another machine (or after system-wide reinstallation) is not to use the channel, but pin everything with fetchers and hashes instead. When updating, you’ll need to
nix-prefetchevery pinned source and update the hashes manually inside the configuration files. That makes updating laborious, and being reluctant to update exposes the setup to the risk of newly-discovered security vulnerabilities. -
The configuration can be passed into other flakes. For example, I use Home Manager to manage my per-user dot files, and I could get the system-level configuration by adding the system flake as a flake input:
{ inputs.system-config.url = "git+file:///etc/nixos"; }There are two use cases for me:
pkgsfrom the system: It’s sometimes required to ensure that the version of some user-installed packages be compatible to some others installed system-wide. That’s when
comes in handy.pkgsSystem = inputs.system-config.legacyPackages.${system};- Home Manager
xsessionconfiguration with the desktop environment installed system-wide.