-
-
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
counter-intuitively uses regexp to match packages
#7962
Comments
That is indeed quite bad as an interface. Just jotting an extra possible point in the design space (no idea whether it's a good one, but it's the first that came to my mind while reading this): keep a regex, but don't require it to be a full match. That way |
@thufschmitt I really like this idea! It makes the interface much nicer without losing any power. I thought about potential edge cases, but the ones I came up with (i.e. removing Seems this is a no-brainer with low-risk. I'll take a stab at implementing it! |
Adding I'm more and more leaning towards #7967 to fix these kinds of issues. |
Yeah so I tried it out and you're right, implicit partial matches are problematic. However, we could do a complete match on the identifier that's reported by # nix profile diff-closures
[...]
Version 4 -> 5:
grc: 1.13 → ∅, -105.2 KiB
Version 5 -> 6:
autojump: 22.5.3 → ∅, -133.7 KiB
grc: ∅ → 1.13, +105.2 KiB
Version 6 -> 7:
grc: 1.13 → ∅, -105.2 KiB
profile: -54.2 KiB
[...] This has to be done anyway for backwards-compatibility with packages installed by |
Ok I digged into it a little further and I agree, we need #7967. Everything else is just a hack and bound to cause implicit problems later on. |
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 |
Another issue is that it's not clear what regex dialect is used (is this documented anywhere?), so I have no way of finding out how to use word boundaries, for example. |
@sullyj3 Nix is using the C++ std::regex library, so it follows C++'s modified ECMAScript regex syntax. However there is one exception: This is a good point, though, we should document in general what regex syntax is used for all commands that accept them. |
@iFreilicht Cheers! According to that page, the dialect does support ⮞ nix search nixpkgs '\brip'
error: Invalid escape in regular expression |
@sullyj3 I looked at the actual implementation, and it seems both I created an issue for this: #8768 POSIX extended syntax doesn't have a word boundary escape sequence, but there's |
Hmm, still no joy: ⮞ nix search nixpkgs '[[:<:]]rip'
error: Invalid character class. Possibly it's not supported by whatever library is being used? Edit: |
That is the right place to look in, and it seems you're right :/ Sorry about that. What's your usecase for using a word-boundary in a search anyway? Maybe there's a different solution to your problem? |
I was searching for the
From grepping a cloned copy of nixpkgs it does seem like it's not in there, but that's beside the point. |
Unfortunately piping
|
This is getting a bit off topic apologies. I'll just note that #3047 seems relevant |
No worries, but maybe you could collect these in a new issue similar to this one? We are aware that For more brain-storming kind of threads, you might also want to post on the Nix Forums, either in the #Development or #Help categories. You might find existing threads on the usability problems with nix search there as well. Thank you for taking the time to dig into this! |
Sure, I'll have a crack later this week. |
Regexes are still used in I think I'll close this. If there are still remaining cases, please open a new issue and feel free to mention #7966, I'll add it to the list 👍 |
nix profile
remove and upgrade accept an regexp argument to be able to match specific (or ranges of) packages. This usually results in confusion. Some common errors that people can run into:Forgetting quotation in most shells:
Using wildcards instead of regexp result in confusing error message:
Which
(
and)
?Forgetting regexp and wildcards altogether:
This makes it seem like
vim
was not installed at all, but it just wasn't matched by the regexpvim
, because it should matchflake:nixpkgs#legacyPackages.x86_64-linux.vim
.I'm thinking
nix profile
should only optionally accept regexp and it should be very explicit about it. For instance--regex "your regex"
. It shouldn't be the default to match packages.The text was updated successfully, but these errors were encountered: