`nixos-rebuild` not rebuilding, I think -- no changes in weeks

(I’ve tab-indented the quotes from Bash below for readability. My configuration is here.)

The problem, if it is one

For the last few weeks, every time I run nixos-rebuild switch, nothing seems to happen. It used to be I’d get a ton of “downloading this, installing that” lines; now I only get:

[jeff@jbb-hp17:~/org-roam-search]$ date
  Tue Oct 10 04:22:24 PM -05 2023

[jeff@jbb-hp17:~/org-roam-search]$ sudo nixos-rebuild switch                    [sudo] password for jeff:
  building Nix...
  building the system configuration...
  activating the configuration...
  setting up /etc...
  reloading user units for jeff...
  setting up tmpfiles

[jeff@jbb-hp17:~/org-roam-search]$ date

The following seems to illustrate that nothing in the system has changed for a long time:

[jeff@jbb-hp17:~/org-roam-search]$ nix profile history \
  --profile /nix/var/nix/profiles/system               \
  --extra-experimental-features nix-command
  Version 317 (2023-09-16):
    No changes.

  Version 318 (2023-09-19) <- 317:
    No changes.

  Version 319 (2023-09-22) <- 318:
    No changes.

  Version 320 (2023-09-24) <- 319:
    No changes.

  Version 321 (2023-09-28) <- 320:
    No changes.

[jeff@jbb-hp17:~/org-roam-search]$

Although I’m not sure I understand that command correctly, because it’s not showing anything from when I rebuild yesterday (Oct 9 2023) or today (Oct 10 2023).

Can it be that none of the myriad packages I use has been changed in nixpkgs in all this time?

The only thing I can think of that I’ve changed recently are

(1) To be almost always on my mobile hotspot rather than wifi – but the last of the versions listed above was built over wifi.

(2) To have disabled autoUpgrade – but if anything, that should make it more likely, when I rebuild by hand, that I see things being downloaded and installed.

to me it sounds like you didn’t change your configuration but would like to keep your system up to date. if you use a conventional configuration you would need to update your channels.
https://nixos.org/manual/nix/stable/command-ref/nix-channel.html
(use sudo to update system channels)
or your need to update your flake lock:
https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-flake-update.html

Thanks! sudo nix-channel --update nixos did the trick!

I used to have autoUpgrade enabled in my configuration. I had assumed all that does is run nixos-rebuild switch each night. Does it also update the channel? (The Wiki article about it doesn’t say.)

I also don’t know
but the manual is a more reliable source then the wiki

Yes, because without channel updates nix will dutifully rebuild the exact same thing over and over again. Same channel (version) = same output, this is a core principle of nix.

It uses the --upgrade flag on nixos-rebuild to achieve this channel update, though: https://github.com/NixOS/nixpkgs/blob/5a237aecb57296f67276ac9ab296a41c23981f56/nixos/modules/tasks/auto-upgrade.nix#L205

This is subtly different because it doesn’t upgrade all channels, so if you have any channels not named nixos, maybe consider updating those too.

Flakes for system config are nice if you use them anyway, by the way, flake.lock files are much more predictable than channels.

why are flake lock files more predictable?

Because they are files in the project, and therefore more intuitively manageable than a singleton configuration object managed separately, potentially independently across multiple machines.

With one you have no idea under which your project is being evaluated, with the other the version is tightly coupled with the project.

You also don’t see changes to the nix channels the same way, they are mostly hidden to you, so if you don’t know how it all works you might not pick up on e.g. removing autoUpgrade suddenly making updates not work at all.

1 Like

The greatest benefit I found with flake.lock is that since it’s tracked with your config repo, you can easily go backwards if you update and find that your system doesn’t work right. This is different than merely rolling back - you might find that you want to experiment with your config before rolling forward an update, and then switch to another branch to still be on an older version (especially with multiple machines). Maybe there is a way with channels, but I always found channels to be opaque and frustrating where the lockfile makes it easy to control exactly what the inputs are.