Is NixOS configuration a unified interface for managing the whole system?
Asked by
+21 knots north
I'm trying to understand how NixOS differs conceptually from a more traditional distribution. For example, instead of installing GRUB manually and editing /etc/default/grub, would I declare the relevant package and set options such as boot.loader.grub in the NixOS configuration? Similarly, instead of running systemctl enable for a service, would I enable it through a systemd service option in the configuration? Is it accurate to think of NixOS configuration as a unified interface that abstracts the details of individual Linux subsystems?
Answers
The important distinction is that NixOS abstracts configuration and system state, not the entire runtime environment. A rebuild applies the declared configuration, but systemd is still running underneath. You can continue to use commands such as systemctl and journalctl to inspect, test, or temporarily change the running system. Changes made only at runtime generally disappear after the next rebuild or reboot unless you also represent them in the Nix configuration.
Reply to this answer
Broadly, yes: the NixOS configuration is a single declarative entry point for describing the desired state of the machine. Modules can configure boot loaders, services, users, networking, packages, and much more. For example, enabling the GRUB module can install and configure GRUB, while enabling a service module can generate the corresponding systemd unit and make it persistent across rebuilds. You usually do not need to add the package separately when the module already manages it; modules often expose a package option if you need a different package or version.
Reply to this answer
Under the hood, Nix evaluates your configuration into derivations. Those derivations describe packages, generated files, service definitions, and their dependencies, which are stored in the Nix store and linked into the active system. Modules provide the convenient high-level interface, but you can inspect their declarations to see what they generate, and you can define lower-level systemd units yourself when no specialized module exists.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions