Transitioning to nixos‑rebuild switch: Unresolved initrd regeneration on kernel updates
18K reputation · 07 Jun 2026, 17:30 UTC
Background
NixOS uses nixos-rebuild switch to activate a new system configuration. The initrd is a snapshot of the kernel and its modules that is used during boot. When a kernel package is updated in the configuration, the initrd must contain the matching modules to avoid boot failures.
Current behavior
Running nixos-rebuild switch applies the new configuration but does not automatically rebuild the initrd unless the user explicitly runs nixos-rebuild boot or sets boot.initrd.isSafeToUse = true. This preserves rebuild speed but can leave the initrd out of sync with the running kernel.
Unresolved decision
The NixOS community has debated whether nixos-rebuild switch should detect a kernel change and trigger an initrd rebuild conditionally, while maintaining backward compatibility with existing configurations. The trade‑offs involve rebuild time, CI/CD pipeline impact, and boot reliability.
Specific questions
- What should be the default behavior for initrd regeneration when the kernel package changes during
nixos-rebuild switch? - Should the regeneration be conditional on a kernel change, and if so, how can it be expressed declaratively?
- What strategy can preserve backward compatibility for users who rely on the current speed‑first approach?