Searching packages: Difference between revisions

Reference to peterldowns/nix-search-cli in the search.nixos.org section, since it uses the same backing elasticsearch instance.
Ole.mn (talk | contribs)
Add `nps` as an option for searching packages
 
(4 intermediate revisions by 3 users not shown)
Line 15: Line 15:
* allows filters
* allows filters
* nice GUI in browser
* nice GUI in browser
* browser extensions possible (like @nixpgs as search engine in Firefox)  
* browser extensions possible (like @nixpkgs as search engine in Firefox)  
; cons:
; cons:
* always requires Internet connection
* always requires Internet connection
Line 21: Line 21:


If you'd like to search with this web service from the command line, you may use [https://github.com/peterldowns/nix-search-cli peterldowns/nix-search-cli]. It provides exactly the same search experience by default.
If you'd like to search with this web service from the command line, you may use [https://github.com/peterldowns/nix-search-cli peterldowns/nix-search-cli]. It provides exactly the same search experience by default.
== Other online sites for searching ==
These are another possible places to search
* [https://github.com/search?q=language%3ANix+&type=code github.com] - search for regex/strings in nixpkgs, home-manager, nix-darwin and any other public github repos.
* [https://mynixos.com mynixos.com] - search for packages in nixpkgs, also nixos, home-manager, nix-darwin options. Not foss and unofficial.
* [https://home-manager-options.extranix.com home-manager-options.extranix.com] - search for home-manager options. [https://github.com/mipmip/home-manager-option-search foss]


== Using the <code>nix search</code> command ==
== Using the <code>nix search</code> command ==
Line 34: Line 42:
* requires disk space for caching
* requires disk space for caching
* quite long command  
* quite long command  
There are third party tools that allow searching for packages similarly to <code>nix search</code>, namely:
* [https://github.com/diamondburned/nix-search diamondburned/nix-search]: A faster and channel-compatible <code>nix search</code> using only stable Nix tools (no [[flakes]] required) which creates a local database with a package index.


== Using the <code>nix-env</code> command ==
== Using the <code>nix-env</code> command ==
Line 43: Line 55:
; cons:
; cons:
* it's very slow and requires a lot of memory
* it's very slow and requires a lot of memory
== Using the <code>nps</code> command ==
<code>nps</code> caches entire <code>nix search nixpkgs ^</code> and <code>nix-env -qaP --description</code> results locally and queries the cache.
<syntaxhighlight lang="bash">nps firefox</syntaxhighlight>
; pros:
* works offline
* very fast
* easy syntax
* output sorted by relevance
; cons:
* [https://github.com/OleMussmann/nps/blob/main/README.md third party program]
* [https://github.com/OleMussmann/nps/blob/main/README.md#automatic-cache-refresh-optional-recommended- cache needs regular refreshing (automatable)]


== Using the <code>nix repl</code> environment ==
== Using the <code>nix repl</code> environment ==