So I am on the nixos-unstable channel and for some time now it is stuck on Hydra and thus does not update. Worse even, if I do a nix-channel --update
it will move my channel to a point where the build of my configuration.nix
does not complete.
Now of course I can move back to a previous generation of my profile and my system is perfectly usable. But I also want to modify my configuration.nix
and rebuild my system (today I had to add a new wifi). So I have to roll back the channel. Still easy.
Sometimes I happen to execute sudo nixos-rebuild --update switch
by habit. Now I have two “unusable” generations of the channel and have to nix-channel --rollback
twice before I can rebuild my configuration.
After going into /nix/var/nix/profiles/per-user/root
and finding the correct generation number that I want to use with nix-channel --rollback N
I have now scripted the process:
cd /nix/var/nix/profiles/per-user/$(whoami) \
&& ls -tl chan* \
| fzf \
| sed -n 's/.*channels-\([0-9]\+\)-link -> .*/\1/p' \
| xargs --no-run-if-empty -n1 nix-channel --rollback
In the end this snippet might be useful to you if
- the channel you are on sometimes can be updated but then breaks the rebuild of your configuration
- you want to check which generations of the channel you have and which is the current
Or do you have other or better solutions for this problem?