Skip to content

Conversation

@sophrosyne97
Copy link

Since calling nix search without a search string is likely to occur by mistake it should not try to match for all packages.
Given how long particular full searches can take a full match should occur from the '--all' flag.
Instead, empty searches now throw an error to the user.

Closes issues #4739 and #3553

(Note: for #3553 I opted to make nix-search throw an error on an empty search instead of show the help message due to it being an InstallableCommand, which meant that it would only show the help message if there was a flake in the current directory and throw an error otherwise. )

@ShamrockLee
Copy link
Contributor

Tested using nix shell github:sophrosyne97/nix/master
LGTM

  • system: "x86_64-linux"
  • host os: Linux 5.4.112, NixOS, 20.09.20210430.be58d0f (Nightingale)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.4pre20210326_dd77f71
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

Copy link
Member

@thufschmitt thufschmitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of small suggestions to extend the documentation and the tests, but otherwise looks good

@edolstra
Copy link
Member

edolstra commented Jun 2, 2021

I'm not sure I agree with the premise that not specifying a regex is likely an error. nix search <flake> is a convenient way to show all the packages in a flake.

Given how long particular full searches can take a full match should occur from the '--all' flag.

Every search is a full search. The regex just restricts what gets printed.

@sophrosyne97
Copy link
Author

I'm not sure I agree with the premise that not specifying a regex is likely an error.

Perhaps not likely for someone familiar with the command, but I would say it is likely an error for new users.
I made the mistake #3553 mentions myself when I was first trying out the experimental features for nix and couldn't really tell if the full search was a bug or a feature as it was happening. This flag would save new users time and from confusion in the future.

Although an empty search is quick, it is inconsistent with most common search commands which assume that every search begins as an empty one. This idiosyncrasy can make even those familiar with the command error prone as shown with #4739, which in the long run can make the feature not so quick. I thought that the short flag '-a' might bridge the gap between being convenient and quick while also demanding explicit user intent for a full search. That way we can stop the unpleasant experience of having the terminal lock up and make the command a little more predictable.

@edolstra edolstra added the UX The way in which users interact with Nix. Higher level than UI. label Sep 27, 2021
@edolstra edolstra added this to the nix-3.0 milestone Sep 27, 2021
@kanashimia
Copy link
Member

Another way would be to do what grep does:

›printf '%s\n' {1..3} | grep
Usage: grep [OPTION]... PATTERNS [FILE]...
Try 'grep --help' for more information.

›printf '%s\n' {1..3} | grep ''
1
2
3

Or print info message to stderr, something like:

›nix search
evaluating packages... (this may take long time)

Also flake version of nix search does not have this problem, right?

@edolstra edolstra modified the milestones: nix-2.5, nix-2.6 Dec 2, 2021
@edolstra edolstra modified the milestones: nix-2.6, nix-2.7 Jan 21, 2022
@edolstra edolstra modified the milestones: nix-2.7, nix-2.8 Mar 3, 2022
@SuperSandro2000
Copy link
Member

@sophrosyne97 can you rebase?

@edolstra edolstra modified the milestones: nix-2.8, nix-2.9 Apr 14, 2022
@sophrosyne97
Copy link
Author

@sophrosyne97 can you rebase?

Rebased and tested.

@edolstra edolstra modified the milestones: nix-2.9, nix-2.10 May 27, 2022
@edolstra edolstra modified the milestones: nix-2.10, nix-2.11 Jul 11, 2022
@SuperSandro2000
Copy link
Member

Can you rebase on master and fix the failing test?

@edolstra edolstra modified the milestones: nix-2.11, nix-2.12 Aug 25, 2022
@edolstra edolstra removed this from the nix-2.12 milestone Dec 6, 2022
@edolstra edolstra modified the milestones: nix-2.13, nix-2.12 Dec 6, 2022
@edolstra edolstra modified the milestones: nix-2.13, nix-2.14 Jan 17, 2023
@edolstra edolstra modified the milestones: nix-2.14, nix-2.15 Feb 28, 2023
@edolstra edolstra modified the milestones: nix-2.15, nix-2.16, nix-2.17 May 26, 2023
@SuperSandro2000
Copy link
Member

@thufschmitt could you review this?

@Ericson2314 Ericson2314 added the new-cli Relating to the "nix" command label Jun 14, 2023
@edolstra edolstra modified the milestones: nix-2.17, nix-2.18 Jul 24, 2023
@edolstra edolstra changed the title Add nix-search --all Add nix search --all Aug 11, 2023
@github-actions github-actions bot added documentation with-tests Issues related to testing. PRs with tests have some priority labels Aug 11, 2023
@roberth
Copy link
Member

roberth commented Aug 11, 2023

This PR was discussed in the Nix team meeting today:

  • @edolstra, @roberth prefer the math simplicity of current implementation
  • @tomberek: probably bigger issue is forgetting to specify the flakeref
  • @edolstra: let's close or postpone
  • @Ericson2314: It seems what is what is actually bugging people is that control-C is not working well (a separate issue). So they accidentally spam their terminally with a huge list of packages and then cannot easily get out of it. So if we solve that problem (fix C-c, page output) then this won't be so bad.

Decision: close

@roberth roberth closed this Aug 11, 2023
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-08-11-nix-team-meeting-79/31627/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation new-cli Relating to the "nix" command UX The way in which users interact with Nix. Higher level than UI. with-tests Issues related to testing. PRs with tests have some priority

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

9 participants