Linux

Where Is the NixOS Configuration File?

NixOS system config at /etc/nixos, hardware scan output, rebuild command, and flakes path.

Last updated

NixOS manages the whole system from one declarative file at /etc/nixos/configuration.nix. Packages, services, users and hardware all flow from it, and nothing applies until you run a rebuild.

Fresh installs generate the file plus a hardware-configuration.nix scan via nixos-generate-config. Flakes move the entry to flake.nix in the same directory while keeping configuration.nix as a module.

Where NixOS stores this, by platform

Linux
/etc/nixos/configuration.nix

Primary module importing ./hardware-configuration.nix. Apply with nixos-rebuild switch. Flakes read /etc/nixos/flake.nix if present. Custom locations work via NIX_PATH or --flake /path/to/flake.

Frequently asked questions

How do I regenerate NixOS hardware config?

Run nixos-generate-config, which rewrites hardware-configuration.nix from the current scan. Keep your hand edits in configuration.nix or separate modules so rescans never clobber them.

Where is the config during installation?

Under /mnt/etc/nixos/configuration.nix from the installer environment. Edit it there before nixos-install so first boot already carries users, bootloader and desktop choices.

Notice an outdated path? Let us know.