-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
entries need stable identifiers
#7967
Comments
I think adding a But we might want to think about the priority of the sources for the name. I think the most sensible source in the majority of cases is the store path. This is what
Hmm but isn't this something like
I would also add that the name must be unique in the profile. This should be checked for before trying to generate the json file, and give the same recommendation of using --name. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/flakes-as-a-unified-format-for-profiles/29476/1 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/flakes-as-a-unified-format-for-profiles/29476/2 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/flakes-as-a-unified-format-for-profiles/29476/17 |
A related issue here is that the So when a user runs I do think we can make educated guesses that work for 98% of users 98% of the time, and we could also let users refer to entries with |
I think we can look into improvements on this once we have names in Nix. I was thinking, if the url did not match any entry, but its name does match, Nix can output a suggestion.
Though it would be nice if nixpkgs#firefox by itself would match as well. Resolving it to the same form as originalUrl and attempt a match using that might be a good step as well. |
#9656 has been merged. Nix profile now has named entries! The suggestion when the installable isn't matching is a next step. Resolving the installable uri before matching is another. |
nix profile
has a number of UX issues related to identifying installed packages.nix profile
s upgrade and remove have counter-intuitive argument #7960nix profile
subcommands rely on index identifier #7961nix profile
counter-intuitively uses regexp to match packages #7962These issues can be resolved by using more human identifiers for profile entries.
Currently the only identifier that we use at the moment is the index of installed packages. For instance, to remove a single package you need to
nix profile remove 3
to remove the 4th entry in the Nix profile.It is possible to start supporting other identifiers, like the original installable (like
github:nixos/nixpkgs/nixpkgs-unstable#cowsay
), but this still gives a bad UX in general use.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
difftastic
, which is what I presume would be possible usingnix profile remove difftastic
.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 name would be inferred from the installable/URL. The name would be set by conditions in order upon installing:
--name
flag#
: for instancegithub:nixos/nixpkgs/nixos-unstable#difftastic
->difftastic
github:cachix/devenv/v0.5
->devenv
.~/projects/mypackage
->mypackage
~/projects/mypackage.nix
->mypackage
--name
explicitly.This would also, in many cases, avoid the need for the regular expression feature of
nix profile remove
andnix profile upgrade
. See #7962.If you then install something that has the same 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. This would resolve #7963.
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:
It could look like:
But for backwards compatibility, we could also just add a property to each element called
name
.Is this something that is viable for
nix profile
?The text was updated successfully, but these errors were encountered: