-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Declarative env management with nix profile is too hard #11544
Comments
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Can this be made to work with The documentation is rather flake-oriented, but does list |
I did experiment with Probably it would work with some change to my overall scheme, but it's clearly not very easy way to go either as I have no idea what precisely I would have to change. |
I can confirm the |
If your profile consists of only one |
Huh, I can set my profile with |
Doesn't seem to work. I removed one package from my It said no priviledge to do so. That's already bad, I shouldn't need super user priviledges to change my own user environment. Still, i attempted the same command with sudo, and it didn't do anything. Am I doing something wrong? |
Never mind! the correct command was So my problem is solved. The question remains though whether it's easy enough for the user to figure out s/he should be looking at |
Too hard IMO. |
Describe the bug
So, I'm wanting to migrate my personal Nix configurations to flakes. I figured out that since the new-gen nix commands are needed to understand flakes, I should migrate my commands before I start rewriting my .nix files.
I'm managing my user environment declaratively, pretty much how the NixPkgs manual suggests except I put the
buildEnv
derivation as the top-level expression of the file. By runningnix-env -irf file.nix
the user environment gets rebuilt transactionally in a single step, just like NixOS gets withsudo nixos-rebuild switch
.Now, turns out the experience of trying to do the same with
nix profile
is subpar. First off, I can't do it transactionally with one command. I have to writenix profile remove '.*'
followed bynix profile install -f file.nix
.If I try writing a bash script to automate this there's another problem. If the installation of the new profile fails, I want to roll back. But how is the script supposed to know what profile number to roll back to? There is no (documented) command to query the number of the current profile before the remove command.
nix profile history
indicates the current generation only by colour of the profile number in question.Maybe with enough bash-fu I could extract the coloured number but frankly, this is way too hard. Unless I'm mistaken, I should be able to use
nix profile
as a drop-in replacement fornix-env
. This is pretty far from it.nix-env --version
outputnix-env (Nix) 2.18.5
The text was updated successfully, but these errors were encountered: