Nixos fails to rebuild

I have done an update. I ran ‘sudo nix flake update’ then ‘nh os switch’

It ran through and made all the upgrades.

But failed to rebuild with this error message

dbus-implementation : dbus -> broker

Switching into this system is not recommended.
You probably want to run 'nixos-rebuild boot' and reboot your system instead.

If you really want to switch into this configuration directly, then
you can set NIXOS_NO_CHECK=1 to ignore pre-switch checks.

WARNING: doing so might cause the switch to fail or your system to become unstable.

Pre-switch check 'switchInhibitors' failed
Pre-switch checks failed
Error: 
   0: Activation (test) failed
   1: Activating configuration (exit status Exited(1))

Location:
   src/commands.rs:739

Is there any thing I can do to allow this to rebuild

I’m on the unstable branch.

It tells you what to do :slight_smile:

Since you’re using nh, run nh os boot instead of switching.

2 Likes

Hi,

I fixed it by adding services.dbus.implementation = “dbus” to my configuration.nix

Thanks

Here’s what’s going on in plainer English:

You’re using the switch command. That subcommand will change your system configuration while the system is running.

Often, this is fine. You might want to install a new application or something, and just adding a new binary to your system is unproblematic.

When updating, however, your configuration might change the version of a service that’s already running, for example the kernel, systemd, or dbus.

For low-level enough services, to actually perform this upgrade you need a reboot. You can’t just swap out the systemd binary and have things work. Since other services might be configured to use the new version, and rely on that version actually running, using the switch command would break your system, or at least result in subtle issues.

As such, for updates that affect something like the kernel, systemd, or dbus, you need to apply them with a reboot.

This has always been the case, but apparently NixOS unstable now has a feature that will prohibit using switch altogether if it’s going to cause issues.

NixOS unstable also changed the default implementation from the reference implementation to broker. This makes a lot of sense and fixes some bugs. This also triggers the switch prohibition, because dbus is one of those services you can’t update without a reboot.


tl;dr: what you should be doing is removing that setting again, and following @waffle8946 's advice to use nh os boot and reboot.

2 Likes

Thanks,

I did what you suggested and it worked.