"sudo nixos-rebuild switch --upgrade" does not get updates anymore

(yes, I saw Sudo nixos-rebuild switch does nothing - #14 by nixy, not relevant)

a couple of weeks back, when running “sudo nixos-rebuild switch --upgrade”, I got the error message (no clue how I managed that)

error: reading symbolic link ‘/root/.local/state/nix/profiles/channels/nixos-unstable-small’: No such file or directory
Command exited with non-zero status 1

After a suggestion on Discord, I ran “sudo nix-channel --update”, and the error went away.

Since then, when I run “sudo nixos-rebuild switch --upgrade”, I get “unpacking channels…” and nothing else, when I know from the channel status page at https://status.nixos.org/ that I should be getting some updates.

Any suggestion? I don’t use flakes for my /etc/nixos/configuration.nix.

I am thinking of converting my configuration to flakes and try that. Then there is the nixos-rebuild shell script to go through.

$ nix-info -m
- system: `"x86_64-linux"`
- host os: `Linux 6.1.15, NixOS, 23.05 (Stoat), 23.05pre460365.3c5319ad3aa`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.14.1`
- channels(root): `"nixos, nixos-unstable-small"`
- channels(oo): `"nixpkgs"`
- nixpkgs: `/home/oo/.nix-defexpr/channels/nixpkgs`
$ nix --version -vv
nix (Nix) 2.14.1
System type: x86_64-linux
Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /home/oo/.config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/oo/.nix-profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/oo/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/n6vimgasfqxz4xbmbzyvh61llhrapya7-nix-2.14.1/share
$ sudo nix-channel --list
nixos https://nixos.org/channels/nixos-unstable-small

Just a shot “shot in the dark” but do you get any more helpful output passing the --verbose flag?

I’m not sure why it’s using /root/.local/state/nix/profiles/channels/nixos-unstable-small’

this usually hangs out in


what does ~/.nix-defexpr/channels point to… i got a feeling that is managed or dangling.

I am guess nixos-rebuild switch --upgrade just runs nix-channel --update, unless it implements itself again… I’d have to check…

here is the output of “sudo nixos-rebuild switch --upgrade --verbose”, minus a lot of “evaluating…” lines in the middle

$ nix-channel --update nixos
unpacking channels...
$ nix-build --no-out-link --expr with import <nixpkgs/nixos> {}; config.system.build.nixos-rebuild --verbose
evaluating file '/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/default.nix'
evaluating file '/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/lib/eval-config.nix'
evaluating file '/nix/store/m3wxbkqcglfqhqa3ffq784rzsrg9kyhf-nixos/nixos/pkgs/development/python-modules/types-psutil/default.nix'
evaluating file '/nix/store/m3wxbkqcglfqhqa3ffq784rzsrg9kyhf-nixos/nixos/pkgs/development/python-modules/mypy/extensions.nix'
$ sudo --preserve-env=NIXOS_INSTALL_BOOTLOADER -- nix-env -p /nix/var/nix/profiles/system --set /nix/store/65r3x5pz92inck4xhdm3mvvkpk21av2y-nixos-system-nixos-23.05pre460365.3c5319ad3aa
$ sudo --preserve-env=NIXOS_INSTALL_BOOTLOADER -- /nix/store/65r3x5pz92inck4xhdm3mvvkpk21av2y-nixos-system-nixos-23.05pre460365.3c5319ad3aa/bin/switch-to-configuration switch
activating the configuration...
setting up /etc...
reloading user units for oo...
setting up tmpfiles

I cannot say from this output why it doesn’t download updates.

following the links…

$ sudo ls -la /root/.nix-defexpr
total 8
drwx------ 2 root root 4096 Apr  7 18:35 .
drwx------ 9 root root 4096 Apr  7 13:03 ..
lrwxrwxrwx 1 root root   40 Apr  7 18:35 channels -> /root/.local/state/nix/profiles/channels
$ sudo ls -laF /root/.local/state/nix/profiles/channels
lrwxrwxrwx 1 root root 16 Apr  7 18:35 /root/.local/state/nix/profiles/channels -> channels-43-link/
$ sudo ls -lat /root/.local/state/nix/profiles/
total 180
drwxr-xr-x 2 root root 4096 Apr  7 18:35 .
lrwxrwxrwx 1 root root   16 Apr  7 18:35 channels -> channels-43-link
lrwxrwxrwx 1 root root   60 Apr  7 13:29 channels-43-link -> /nix/store/22430hw1409ip3iy631frfbhd9l8msw7-user-environment
lrwxrwxrwx 1 root root   60 Apr  7 06:52 channels-42-link -> /nix/store/rfd6kbaf5im2qp4w2lf9swiyanln092q-user-environment
lrwxrwxrwx 1 root root   60 Apr  6 04:40 channels-41-link -> /nix/store/wlcz40h15hgj69qclq6xsrcwy8x22hbd-user-environment

and also:

$ ll /nix/var/nix/profiles/per-user/root/
total 4
lrwxrwxrwx 1 root root 17 Mar  5 10:09 channels -> channels-507-link
lrwxrwxrwx 1 root root 60 Mar  5 10:09 channels-507-link -> /nix/store/7j0bgk2kyf28vrb5dhxllqr6icvl79sq-user-environment

I don’t see anything broken so far.

I don’t have anything in this /root/.local/state/nix

So this might be new, or changed …perhaps someone can tell me.


maybe this is related …

are you use moan manager as well, i’m sorry i mean home manager ?

2.14s XDG based update is my suspicion for using that location.

interesting! I do not use home-manager, but my nix --version = 2.14.1. I think my troubles began shortly after the release of nix 2.14.1.

Now how do I revert to the recommended nix 2.13.3? nix-env leaves out root. Perhaps some overlay in my /etc/nixos/configuration.nix?

2.13 is EOL.

From my understanding of the unwritten policy only the current minor and the default of the last stable NixOS release are “supported” at all.

Anyway, on NixOS you can change the version of nix by setting nix.package to one of the available nix packages.

1 Like

I set nix.package = pkgs.nixStable in my configuration.nix and ran “sudo nixos-rebuild switch”, after which I had nix --version = 2.13.3.

The second “sudo nixos-rebuild switch --upgrade” did download a bunch of updates (it’s still not done with the compiling!).