-
-
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
'nix profile' has terrible experience upgrading packages #7530
Comments
I've had similar experiences with A couple other related issues:
while this does work:
These would end up conflicting when you upgrade I think. |
Haven't tested it , but maybe something like this would help for the first problem:
|
Reminds me of #4482 |
Maybe nix profiles need to be rethought of. Both upgrade and remove have a bad experience, even if you know your way around Nix. The problem is that Nix doesn't know about simple names of individual packages. For instance, installing the latest version of difftastic using:
Will nicely install difftastic, but I cannot refer to the entry using Would it be possible to store (for each entry in profile) a simple name that is (by default) inferred from the "installable" argument?
By default the 'entry-name' would be inferred from the URL. The name would be set by conditions in order upon installing:
This would also in many cases avoid using the regular expression feature. This feature currently could be considered bad practice, as it quickly results in unintended errors. As well as bad UX, as it needs If you then install something that has the same 'entry-name', the installation can warn or error that the entry name already exists and maybe asks or suggests how to upgrade the package to the new URL. The numbers would also not be needed anymore. Those numbers seem like a kind of priority, but priority is something entirely different. The numbers are currently merely identifiers for installed packages: much better suited for unique names. Would something like this be viable for profiles? EDIT: I did some more digging. The manifest.json currently looks like: {
"elements": [
{
"active": true,
"attrPath": "legacyPackages.x86_64-linux.difftastic",
"originalUrl": "github:nixos/nixpkgs/nixos-unstable",
"outputs": null,
"priority": 5,
"storePaths": [
"/nix/store/87a50y83m4hg20ms5ch5x2vjdi7lzs0s-difftastic-0.43.0"
],
"url": "github:nixos/nixpkgs/0591d6b57bfeb55dfeec99a671843337bc2c3323"
},
...
],
"version": 2
} It could look like: {
"elements": {
"difftastic": {
"active": true,
"attrPath": "legacyPackages.x86_64-linux.difftastic",
"originalUrl": "github:nixos/nixpkgs/nixos-unstable",
"outputs": null,
"priority": 5,
"storePaths": [
"/nix/store/87a50y83m4hg20ms5ch5x2vjdi7lzs0s-difftastic-0.43.0"
],
"url": "github:nixos/nixpkgs/0591d6b57bfeb55dfeec99a671843337bc2c3323"
},
...
},
"version": 3
} EDIT2: I don't want to go overboard in this issue, but in terms of UX it would be even nicer if this could integrate better with declarative configurations like home-manager as well. Make it possible to have |
There are quite a few UX problems with $ nix profile install github:cachix/devenv/latest
$ nix profile upgrade github:cachix/devenv/latest
warning: 'github:cachix/devenv/latest' does not match any packages
warning: Use 'nix profile list' to see the current profile.
$ nix profile remove devenv
warning: 'devenv' does not match any packages
warning: Use 'nix profile list' to see the current profile.
The main identifier for package entries is the index. The index is quite bad as an identifier: $ nix profile list
....
3 flake:nixpkgs#legacyPackages.x86_64-linux.vim github:NixOS/nixpkgs/9952d6bc395f5841262b006fbace8dd7e143b634#legacyPackages.x86_64-linux.vim /nix/store/9hcby08vmd6k3zl3clwvlw5y5vkmc3z6-vim-9.0.0609
4 flake:nixpkgs#legacyPackages.x86_64-linux.cowsay github:NixOS/nixpkgs/9952d6bc395f5841262b006fbace8dd7e143b634#legacyPackages.x86_64-linux.cowsay /nix/store/azn0g0m6yg6m9vmdp3wq6wjbsd1znv44-cowsay-3.7.0 /nix/store/qgsl9bd6vvnpjaxhdnzg0xmycg3652c0-cowsay-3.7.0-man
5 flake:nixpkgs#legacyPackages.x86_64-linux.nano github:NixOS/nixpkgs/9952d6bc395f5841262b006fbace8dd7e143b634#legacyPackages.x86_64-linux.nano /nix/store/hhr8ijr2p5qf3lyklzyw8cndhsmpklsv-nano-7.2
$ nix profile remove 3
removing 'flake:nixpkgs#legacyPackages.x86_64-linux.vim'
$ nix profile remove 4
removing 'flake:nixpkgs#legacyPackages.x86_64-linux.nano' In this case the numeric identifier in
As an alternative to the identifier, there is the use of regexp to match specific packages. This usually results in confusion: Forgetting quotation in most shells: $ nix profile remove .*vim.*
fish: No matches for wildcard '.*vim.*'. See `help wildcards-globbing`.
nix profile remove .*vim.*
^~~~~~^ $ nix profile remove .*vim.*
zsh: no matches found: .*vim.* Using wildcards instead of regexp result in confusing error message: $ nix profile remove '*vim*'
error: Mismatched '(' and ')' in regular expression Which Forgetting regexp and wildcards altogether: $ nix profile remove vim
warning: 'vim' does not match any packages
warning: Use 'nix profile list' to see the current profile. This makes it seem like This imo is also solved when using proper identifiers for packages. Multiple installs result in multiple entries, even though they conflict with each-other: $ nix profile install github:cachix/devenv/latest
$ nix profile install github:cachix/devenv/latest
$ nix profile install github:cachix/devenv/latest
$ nix profile list
...
3 github:cachix/devenv/latest#defaultPackage.x86_64-linux github:cachix/devenv/15445416534c6253a78c4eb1f803af0338ead497#defaultPackage.x86_64-linux /nix/store/j5v7sh1ii9vv1bw9ngzdh5h76hh0zljh-devenv
4 github:cachix/devenv/latest#defaultPackage.x86_64-linux github:cachix/devenv/15445416534c6253a78c4eb1f803af0338ead497#defaultPackage.x86_64-linux /nix/store/j5v7sh1ii9vv1bw9ngzdh5h76hh0zljh-devenv
5 github:cachix/devenv/latest#defaultPackage.x86_64-linux github:cachix/devenv/15445416534c6253a78c4eb1f803af0338ead497#defaultPackage.x86_64-linux /nix/store/j5v7sh1ii9vv1bw9ngzdh5h76hh0zljh-devenv
Installing packages from different sources results in huge downloads. It's hard to avoid this: $ nix profile install github:nixos/nixpkgs/nixpkgs-unstable#cowsay
# A week later:
$ nix profile install github:nixos/nixpkgs/nixpkgs-unstable#vim Now 2 different versions of nixpkgs are pinned this has a few downsides:
There are some advantages to having a nixpkgs-pin per package, but currently it is the default and shouldn't be something the user needs to handle. The main selling point of Nix is reproducibility. However, since $ nix profile install nixpkgs#cowsay
$ nix profile export manifest.json
# On another system:
$ nix profile import manifest.json
# Or:
$ nix shell --manifest manifest.json
# Or in home-manager:
{
home.profiles.main = lib.importManifest ./manifest.json;
} This is similar to what Guix is already doing: https://guix.gnu.org/manual/devel/en/html_node/Writing-Manifests.html |
Now that #7788 has been merged, thia issue as described is resolved. The title of the issue still applies though 😅 |
Is not a particularly useful message. |
I still feel the upgrade experience is terrible...
|
It's funny because my ixnay wrapper (which I started writing and using precisely because of the original nonsense shown in the earlier part of this ticket) stopped working for upgrading profiles and I arrived here while googling why. Turns out I had written all this code to parse out the correct information given profile numbers including multiple installs of the same package (eyeroll) and you guys went and fixed the TUI UX. ;) So now I have to update my wrapper script, but I'm happy to do so! I use NixOS exclusively, except for when I use Nix on Darwin... so unfortunately I need the imperative-install thing (I suppose I could also use home manager darwin, but not ready to make that leap yet.) |
@pmarreck consider https://github.com/lnl7/nix-darwin, it's a breeze and gets your macOS as close to NixOS as it gets. |
Here's a user session from devenv discord:
❯ nix-env -if https://github.com/cachix/devenv/tarball/v0.5
error: profile '/nix/var/nix/profiles/per-user/i97henka/profile' is incompatible with 'nix-env'; please use 'nix profile' instead
❯ nix profile install github:cachix/devenv/v0.5 --extra-experimental-features flakes
warning: Using saved setting for 'extra-substituters = https://devenv.cachix.org' from ~/.local/share/nix/trusted-settings.json.
warning: Using saved setting for 'extra-trusted-public-keys = devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw=' from ~/.local/share/nix/trusted-settings.json.
error: files '/nix/store/k0gwhiwfs8c218kph78vx75bph51iw31-devenv/bin/devenv' and '/nix/store/7i4hxhw44lr7r64zlmp4zq7cqpsx7smw-devenv/bin/devenv' have the same priority 5; use 'nix-env --set-flag priority NUMBER INSTALLED_PKGNAME' or type 'nix profile install --help' if using 'nix profile' to find out howto change the priority of one of the conflicting packages (0 being the highest priority)
Any pointers on how I can get the upgrade working would be much appreciated!
the fix
nix profile list
andnix profile remove /nix/store/xxxxx
The text was updated successfully, but these errors were encountered: