$ sudo nix-env --list-generations --profile /nix/var/nix/profiles/system
 600   2020-01-25 21:01:11   
 601   2020-02-03 13:44:19   
 602   2020-02-09 14:06:20   
 603   2020-02-09 14:11:11   
 604   2020-02-11 00:02:43   
 605   2020-02-13 12:26:22   
 606   2020-02-16 16:40:02   (current)

How could I get the commit / channel generation (is this a thing?) for a Nixos generation - and potentially rollback the channel to it?

Or in other words, how can I rollback my 'channel state' to what it was at generation 605?

Why I want to know is because I did a sudo nix-channel --update, and sudo nixos-rebuild switch few days ago - however whatever package updates took place - resulted in an unstable system.

So to mitigate this, I booted and continue to use an old generation (605).

I now want to update a specific package in my Nixos system configuration, and base the changes on 605 as opposed to the latest 606.

I did find https://stackoverflow.com/questions/39090387/how-to-undo-nix-channel-update (nix-channel --rollback..) however I may have updated the channels a few times - so the 'last' channel state might not be what I need.

I did notice you can specify a channel generation number as a parameter to this command - but I'm not sure what is the relationship between that and the nixos generation? It does not seem to be the same thing as I tried for 605 with the following results:

sudo nix-channel --rollback 605
error: generation 605 does not exist
error: program '/nix/store/cs47wjxwiqgyl1nkjnksyf3s2rb93piq-nix-2.3.2/bin/nix-env' failed with exit code 1

I assume you want sudo nix-channel --rollback ? For example, you may also manually inspect /nix/var/nix/profiles/per-user/root/channels-*/manifest.nix – those contain name, commit hash, etc.

  • Hmm possibly but in my case I need to rollback to a revision prior to the last. I've updated the question with more info. – Chris Stryczynski Feb 21 '20 at 11:04
  • 1
    605 is surely an incorrect number. The series of channel updates (your nix-channel --update runs) is "independent" of your nix-env updates. If you want the previous one, you just don't specify any number. It can be useful to ls -l /nix/var/nix/profiles/per-user/root/channels-*, as you see timestamps when you did those runs. – Vladimír Čunát Feb 21 '20 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.