Diagnosing NixOS Activation Failures After nixos-rebuild switch
A step‑by‑step diagnostic guide for common NixOS activation failures after nixos-rebuild switch, with checks, fixes, and rollback advice.
05 May 2026, 08:51 UTC

Recognizable Condition
After running nixos-rebuild switch the command aborts with an error or the system appears to reboot but a service fails to start, leaving you unable to log in or use expected functionality.
Cause & Diagnostic Table
| Possible Cause | Typical Symptom / Error Message | Quick Check |
|---|---|---|
Syntax error in configuration.nix (missing semicolon, mismatched brackets) | Evaluation stops early with error: syntax error, unexpected '}' or similar. | Run nix-instantiate --find-file /etc/nixos/configuration.nix; a non‑zero exit indicates a parse problem. |
| Store path mismatch – referenced package not in current Nixpkgs channel | Attribute missing error, e.g. attribute 'hello' missing while evaluating. | Execute nix-instantiate --eval -E 'with import {}; hello'; failure means the package isn’t available. |
| Hardware configuration incompatibility (kernel module, firmware) | Boot stalls or service fails with module xyz not found in journalctl -b -1. | Inspect boot.kernelModules and compare with lsmod output; missing modules indicate mismatch. |
| Service activation failure due to missing user/group or dependency | Service enters failed state; systemctl status <service> shows User "foo" not known or Dependency failed for …. | Check declared users/groups in configuration.nix against cat /etc/passwd and cat /etc/group; verify required packages are listed. |
Ordered Diagnostic Steps
- Validate the Nix expression – run
as root (or withnixos-rebuild testsudo). This builds and activates the configuration in a temporary environment without touching the running system. If it fails, the error originates during evaluation or build. - Check for syntax problems** – if
testfails with a parse error, run
. A clean exit (no output) means the file can be located; any output indicates a problem.nix-instantiate --find-file /etc/nixos/configuration.nix - Verify package availability** – for each custom package or module attribute, test with
. Replacenix-instantiate --eval -E 'with import {}; <attribute>'<attribute>with the suspect name (e.g.,vim). Failure points to a channel mismatch. - Inspect hardware relevance** – look at
boot.kernelModules,hardware.opengl, etc. Compare withlsmodandlspci -k. Missing modules suggest the hardware config is inaccurate for the running machine. - Review service declarations** – examine
services.<service>blocks. Ensure any required users/groups are declared underusers.usersandusers.groups, and that all depended packages appear inenvironment.systemPackagesor the service’srequires. - Check logs after a failed activation** – if
switchappears to succeed but a service fails, run
to see the boot log of the previous attempt. Look for lines containing the service name orjournalctl -b -1failed.
Fixes Tied to Findings
- Syntax error – edit
/etc/nixos/configuration.nixto add the missing semicolon or correct brackets. Re‑runnixos-rebuild testto confirm the error disappears before proceeding toswitch. - Store path mismatch – update the Nixpkgs channel:
or pin a specific revision insudo nix-channel --update nixosconfiguration.nixusingbuiltins.fetchTarball. After updating, repeat the package‑availability check. - Hardware incompatibility – remove or replace the offending kernel module or firmware line in
boot.kernelModules(orhardware.opengl.driSupport, etc.). Re‑runnixos-rebuild test; if the test passes, proceed withswitch. - Service dependency/user issue** – add the missing user/group declaration:
or ensure the required package is listed inusers.users.myapp = { isSystemUser = true; };environment.systemPackagesor the service’sdependsOn. Validate withnixos-rebuild test.
Escalation Criteria & Rollback
If after applying the above fixes the configuration still fails to activate:
- Escalate to the NixOS community (Discourse, Matrix, or GitHub) with the full error output, the relevant snippet of
configuration.nix, and the Nixpkgs channel revision (nix-instantiate --eval -E '(import {}).lib.version'). - As a safety measure, you can rollback to the last known‑good generation without reinstalling:
activates the previous generation’s boot entry. Alternatively, select the earlier entry from the GRUB boot menu.sudo nixos-rebuild switch --rollback
Practical Verification
After a successful nixos-rebuild switch, confirm the change took effect:
- For a package change:
should point to the new store path.which <command> - For a service:
showssystemctl status <service>active (running). - For hardware:
confirms the module is loaded.lsmod | grep <module>
Limitations: nixos-rebuild test and dry-activate do not exercise hardware‑specific code paths (e.g., early boot drivers). A full reboot or nixos-rebuild switch is required to validate those aspects.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.