mirror of
https://github.com/NixOS/nix
synced 2025-06-27 21:01:16 +02:00
parent
17c202b3ea
commit
397cf4e285
4 changed files with 30 additions and 16 deletions
|
@ -67,11 +67,9 @@ struct CmdSearch : InstallableValueCommand, MixJSON
|
|||
settings.readOnlyMode = true;
|
||||
evalSettings.enableImportFromDerivation.setDefault(false);
|
||||
|
||||
// Empty search string should match all packages
|
||||
// Use "^" here instead of ".*" due to differences in resulting highlighting
|
||||
// (see #1893 -- libc++ claims empty search string is not in POSIX grammar)
|
||||
// Recommend "^" here instead of ".*" due to differences in resulting highlighting
|
||||
if (res.empty())
|
||||
res.push_back("^");
|
||||
throw UsageError("Must provide at least one regex! To match all packages, use '%s'.", "nix search <installable> ^");
|
||||
|
||||
std::vector<std::regex> regexes;
|
||||
std::vector<std::regex> excludeRegexes;
|
||||
|
|
|
@ -5,7 +5,7 @@ R""(
|
|||
* Show all packages in the `nixpkgs` flake:
|
||||
|
||||
```console
|
||||
# nix search nixpkgs
|
||||
# nix search nixpkgs ^
|
||||
* legacyPackages.x86_64-linux.AMB-plugins (0.8.1)
|
||||
A set of ambisonics ladspa plugins
|
||||
|
||||
|
@ -34,7 +34,7 @@ R""(
|
|||
* Show all packages in the flake in the current directory:
|
||||
|
||||
```console
|
||||
# nix search
|
||||
# nix search . ^
|
||||
```
|
||||
|
||||
* Search for Firefox or Chromium:
|
||||
|
@ -64,11 +64,16 @@ R""(
|
|||
|
||||
`nix search` searches [*installable*](./nix.md#installables) (which can be evaluated, that is, a
|
||||
flake or Nix expression, but not a store path or store derivation path) for packages whose name or description matches all of the
|
||||
regular expressions *regex*. For each matching package, It prints the
|
||||
regular expressions *regex*. For each matching package, It prints the
|
||||
full attribute name (from the root of the [installable](./nix.md#installables)), the version
|
||||
and the `meta.description` field, highlighting the substrings that
|
||||
were matched by the regular expressions. If no regular expressions are
|
||||
specified, all packages are shown.
|
||||
were matched by the regular expressions.
|
||||
|
||||
To show all packages, use the regular expression `^`. In contrast to `.*`,
|
||||
it avoids highlighting the entire name and description of every package.
|
||||
|
||||
> Note that in this context, `^` is the regex character to match the beginning of a string, *not* the delimiter for
|
||||
> [selecting a derivation output](@docroot@/command-ref/new-cli/nix.md#derivation-output-selection).
|
||||
|
||||
# Flake output attributes
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue