7

After clean installation via NixOps, I logined to machine and executed

# nix-channel --update

This pulled ~130Mb of nixpkgs into my /nix/store. How can I undo this?

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
danbst
  • 3,363
  • 18
  • 38
  • Best to recreate the machine, you can't revert the first channel. – iElectric Aug 23 '16 at 09:33
  • 2
    If this actually updated the channel, `nix-channel --rollback` will undo that (but not free up disk space). If this failed due to lack of disk space, good news is nothing changed to the system setup, and `nix-collect-garbage` should free that back up. – Lily Ballard Sep 16 '19 at 03:52

2 Answers2

11

On a normal Nix or NixOS install, if you've updated your channels by accident with nix-channel --update, you can undo this by running

nix-channel --rollback

See the manual for more details.

On a NixOps installation, channels are configured but not actually used. See the other answer for that.

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347
Evan VanderZee
  • 797
  • 6
  • 10
5

On a NixOps installation it seems that channels are configured, but aren't actually used by NixOps. This means that running nix-channel --update will create the very first generation, and nix-channel --rollback won't work as that can't roll back past the first generation.

The following seems to work for clearing out this information.

Do not run this on a Nix or NixOS install! This is just for NixOps.

rm /nix/var/nix/profiles/per-user/root/channels-1-link
rm /nix/var/nix/profiles/per-user/root/channels
rm ~/.nix-defexpr/channels
nix-collect-garbage -d
Lily Ballard
  • 182,031
  • 33
  • 381
  • 347
danbst
  • 3,363
  • 18
  • 38
  • 3
    Don't do this! You just deleted your channels. – Lily Ballard Sep 16 '19 at 03:51
  • lold. This is actually what OP (me) asked. NixOps deployed machines don't have channels by default. – danbst Sep 17 '19 at 04:36
  • If there are no channels then what did `nix-channel --update` pull from? This suggests that there were in fact channels configured. – Lily Ballard Sep 19 '19 at 00:30
  • 1
    I've just checked a fresh libvirtd NixOps deployment. nix-channel --list shows `nixos https://nixos.org/channels/nixos-unstable`, so yes, there is a channel, which is not pulled. After it is pulled first time, `nix-channel --rollback` doesn't unpull it back. You have either to use suggested solution or 1) delete channel 2) GC 3) readd channel – danbst Sep 20 '19 at 08:14
  • 1
    @danbst this is maybe how _you_ interpret your question but a lot of other readers interpret it otherwise and this for them is harmful advice. – cxandru Sep 24 '19 at 07:28
  • 1
    okay, I've changed an accepted answer to popular one. I hope if anyone will have my problem, they'll still find my current answer to this particular problem. – danbst Sep 24 '19 at 14:50
  • 2
    I'm going to update both answers to make it more clear what question each answer is actually answering. – Lily Ballard Sep 29 '19 at 20:19