[Nix-dev] confusing rollback / generation system
Vladimír Čunát
vcunat at gmail.com
Thu May 18 21:32:09 CEST 2017
On 05/18/2017 08:32 PM, Stefan Huchler wrote:
> [...] Doing something like that:
>
> nix-env -G 198 -p /nix/var/nix/profiles/system
> nix-env --delete-generations 199 200... -p /nix/var/nix/profiles/system
> nix-collect-garbage
>
> The first question is why do I need to specify a path and use a nix tool
> when I want to make nixos system rollback? searching this path always is not
> very funny.
You don't need to. You can run just `nix-env --rollback` repeatedly to
get to the generation you want. Note that it's just a linear list; that
might have "confusing consequences" when you alternate appending items
with rollbacks.
> Why cant I use some sort of nixos-env --delete-generations without a
> path? And why cant I use like with nix-channel not 198 as parameter to
> rollback instead of using switch + delete manually?
If you want to delete all but the current generation or similar actions,
there's `nix-collect-garbage -d` (see docs for more details).
> then I wanted to change back the channel so that upgrades I do with
> nixos-rebuild would use 16.10 packages.
>
> I thought using --add 16.10-url and then --update would be the way to
> go, but I see there is also a rollback option. So lets try it:
>
> /ssh:root at PC: $ nix-env --list-generations
> 18 2017-05-12 04:04:24
> 19 2017-05-12 17:09:26 (current)
> /ssh:root at PC: $ nix-channel --rollback
> switching from generation 19 to 18
> /ssh:root at PC: $ nix-env --list-generations
> 18 2017-05-12 04:04:24
> 19 2017-05-12 17:09:26 (current)
> /ssh:root at PC: $ nix-channel --list
> nixos https://nixos.org/channels/nixos-17.03
>
> It seems to me that it did nothing.
>
> Why is there a second rollback feature? When would be a good time to use
> it, and a new add+update be not doing the same?
Channels have an independent list of generations, "unrelated" to the
generations of installed stuff (nix-env --list-generations). Anyway,
you probably want to remove the 17.03 URL, replace it, and run channel
update.
--Vladimir
P.S.
I personally often like to hand-manage this stuff, as the commands are
just a rather thin layer around the underlying files.
$HOME/.nix-channels is a really trivial list. Profiles are simple
symlinks. It's often easier for me to use standard tools for
manipulation with files and text files.
More information about the nix-dev
mailing list