Re: [Nix-dev] confusing rollback / generation system

2017-05-19 Thread Vladimír Čunát
On 05/19/2017 02:06 AM, Linus wrote:
> Yes, nix-env as root operates on the *default* profile (which applies to
> all users but is independent of nixos-rebuild) and not the *system*
> profile (which is operated on by nixos-rebuild) by default. [...]

Right, thanks, I confused those two.  Now I better understand the
original question.  I don't think "NixOS profiles" were meant to be
manipulated by nix-env.
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] confusing rollback / generation system

2017-05-18 Thread Linus
On 18 May 2017 23:40:22 BST, Stefan Huchler  wrote:
>Vladimír Čunát  writes:
>
>> Oh, you mean the system-wide profile?  (i.e.
>> /nix/var/nix/profiles/system)  That's the root's profile.  If you use
>> `nix-env` as root, it will operate on that by default.  You typically
>> need elevated privileges, but it's probably possible to change
>> permissions of that directory...
>
>At least for --list-generations operation that is not true tested on 2
>machines. I have to set the system-directory parameter to get access to
>it.
>
>bash-4.4# nix-env --list-generations
>  16   2017-01-10 09:28:31   (current)
>
>bash-4.4# nix-env --list-generations -p /nix/var/nix/profiles/system
>  71   2017-04-02 20:01:34   
>  72   2017-04-23 15:36:07   (current)
>
>___
>nix-dev mailing list
>nix-dev@lists.science.uu.nl
>https://mailman.science.uu.nl/mailman/listinfo/nix-dev

Yes, nix-env as root operates on the *default* profile (which applies to all 
users but is independent of nixos-rebuild) and not the *system* profile (which 
is operated on by nixos-rebuild) by default.

I totally agree that this is confusing and that it would be nice to perform 
operations on the system profile using the same set of commands as for other 
profiles, as some can't be performed without using the wordy nix-env -p 
/nix/var/nix/profiles/system. The options provided by nix-collect-garbage are 
far too limited, and affect user profiles in addition to the system profile, 
and AFAIU using nix-env -p /nix/var/nix/profiles/system --switch-to-generation 
xyz won't go as intended.

In short: I think nixos-rebuild should support the same generation-management 
commands as nix-env (--list-generations, --delete-generations, 
--switch-to-generation, don't know if there are any more I've missed) for 
consistency and ease of use. Deleting system generations and leaving user 
profiles alone is currently a pain, unnecessarily so.


(All this IMHO)___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] confusing rollback / generation system

2017-05-18 Thread Stefan Huchler
Vladimír Čunát  writes:

> Oh, you mean the system-wide profile?  (i.e.
> /nix/var/nix/profiles/system)  That's the root's profile.  If you use
> `nix-env` as root, it will operate on that by default.  You typically
> need elevated privileges, but it's probably possible to change
> permissions of that directory...

At least for --list-generations operation that is not true tested on 2
machines. I have to set the system-directory parameter to get access to
it.

bash-4.4# nix-env --list-generations
  16   2017-01-10 09:28:31   (current)

bash-4.4# nix-env --list-generations -p /nix/var/nix/profiles/system
  71   2017-04-02 20:01:34   
  72   2017-04-23 15:36:07   (current)

___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] confusing rollback / generation system

2017-05-18 Thread Vladimír Čunát
On 05/18/2017 11:27 PM, Stefan Huchler wrote:
>> 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.
> with nix-env --list-generations I get that 15-19 generation stuff so
> nix-env rollback would operate on that right?

Right.

> So I need to give the system-path to operate on... to take actions on
> it. I dont see how to get around that...

Oh, you mean the system-wide profile?  (i.e.
/nix/var/nix/profiles/system)  That's the root's profile.  If you use
`nix-env` as root, it will operate on that by default.  You typically
need elevated privileges, but it's probably possible to change
permissions of that directory...

--Vladimir
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] confusing rollback / generation system

2017-05-18 Thread Stefan Huchler
Vladimír Čunát  writes:

> On 05/18/2017 08:32 PM, Stefan Huchler wrote:

>> 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.

with nix-env --list-generations I get that 15-19 generation stuff so
nix-env rollback would operate on that right?

So I need to give the system-path to operate on... to take actions on
it. I dont see how to get around that...

Also repetingly do --rollback 10 times is no good option in my
oppinion... giving a number as parameter makes more sense to
me... which works for nix-channel --rollback but not for nix-env
--rollback which is inconsistent.


>> 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).

delete older does not help when I want to go back... I would need some
sort of --delete-newer-than...


> 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.

Yes that is what I did... still the need of writing the path to the
system-profile is dumb in my oppinion... make some sort of --system
switch or something...

Its just some guessing and trying around thinking that I might need
still a backup of the system... cause there seems so much you can make
wrong.

Sorry maybe I am nidpicking... I dont want to whine but maybe somebody
sees that as good feedback for improvements.

make a nix-env --system or nixos-env tool that operates on the os-level,
or integrate --rollback in nixos-rebuild and rename it maybe to
nixos-ctl or something like that.

> --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.

At least I know I did not start a atomic missle and it was kind of
correct what I did, even it feeled very strange...

___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] confusing rollback / generation system

2017-05-18 Thread Vladimír Čunát
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@PC: $ nix-env --list-generations
>   18   2017-05-12 04:04:24   
>   19   2017-05-12 17:09:26   (current)
> /ssh:root@PC: $ nix-channel --rollback
> switching from generation 19 to 18
> /ssh:root@PC: $ nix-env --list-generations
>   18   2017-05-12 04:04:24   
>   19   2017-05-12 17:09:26   (current)
> /ssh:root@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.

___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev


[Nix-dev] confusing rollback / generation system

2017-05-18 Thread Stefan Huchler
So because I had problems with nixos 17.03 (kodi) for now I wanted to
rollback to a older version and get rid of the newer generations on my
system, so that I can update my 16.10 profile with other configurations.

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.

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?

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@PC: $ nix-env --list-generations
  18   2017-05-12 04:04:24   
  19   2017-05-12 17:09:26   (current)
/ssh:root@PC: $ nix-channel --rollback
switching from generation 19 to 18
/ssh:root@PC: $ nix-env --list-generations
  18   2017-05-12 04:04:24   
  19   2017-05-12 17:09:26   (current)
/ssh:root@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?

Stefan

___
nix-dev mailing list
nix-dev@lists.science.uu.nl
https://mailman.science.uu.nl/mailman/listinfo/nix-dev