I think this previous statement by infinisil gives good context to why system.nix is desirable as a means to canonicalize a configuration file that defines a NixOS system (as opposed to the NixOS module) and making it more ergonomic to use with nixos-rebuild
From Pinning configuration.nix with niv - #4 by Infinisil
… in non-Flake mode, nixos-rebuild always uses <nixpkgs> from NIX_PATH to evaluate the modules, which is why it’s necessary to inject the pinned Nixpkgs “before” calling nixos-rebuild, like I’ve done in sanix, to get it to use a different Nixpkgs.
Note that this could be much simpler if nixos-rebuild got support for e.g. an /etc/nixos/default.nix file that can declare the entry-point for the entire NixOS evaluation. This is not very hard, just nobody has implemented that yet.
And honestly, I think this is the biggest reason why Flakes has been adopted so widely: Eelco did change nixos-rebuild to support this for Flakes, making Flakes the only built-in way for nixos-rebuild to have a declarative Nixpkgs. This makes Flakes look more necessary than it really is to get a stateless NixOS config, when it’s really just a property of nixos-rebuild.
6 Likes