# nixpkgs-search Search [nixpkgs](https://github.com/NixOS/nixpkgs) from your terminal, using the same Elasticsearch backend that powers [search.nixos.org](https://search.nixos.org). Results are piped through `fzf` for fuzzy selection with a live preview of package metadata. ## Usage ```sh nixpkgs-search ripgrep nixpkgs-search --channel 24.11 firefox nixpkgs-search --json hello nixpkgs-search --nixery python git curl nixpkgs-search --nixery --loop python git curl nixpkgs-search --no-fzf --n 20 vim ``` Flags: - `--channel` — nix channel to search (default `unstable`) - `--n` — max results (default `50`) - `--json` — dump raw hits and exit - `--nixery` — select multiple packages and print a `/`-delimited package list for Nixery - `--loop`, `-l` — with `--nixery`, run one picker per query instead of merging all results into one picker - `--no-fzf` — force numeric picker even if `fzf` is available On selection, the chosen attribute name is printed to stdout, so it composes: ```sh nix shell nixpkgs#$(nixpkgs-search ripgrep) ``` When stdout or stderr is not attached to a TTY, `nixpkgs-search` skips the picker and prints a newline-delimited list of matching package attribute names. This is intended for shell completions and scripts: ```sh nixpkgs-search --n 20 rip ``` With `--nixery`, each positional argument is searched independently, all results are merged into one multi-select picker, and the selected attributes are printed as a Nixery path: ```sh docker run -it nixery.dev/$(nixpkgs-search --nixery python git curl) ``` Use `--loop` or `-l` to handle each query in its own picker and join the selections at the end. ## Install / run with Nix Run without installing: ```sh nix run git+https://git.sr.ht/~chiefnoah/nixpkgs-search -- ripgrep ``` Install into a profile: ```sh nix profile install git+https://git.sr.ht/~chiefnoah/nixpkgs-search ``` Or add as a flake input and reference `packages..default`. ## Development A dev shell with Go, `gopls`, staticcheck, `fzf`, and the built binary itself is provided: ```sh nix develop go build ./... go run . ripgrep ``` If you use [direnv](https://direnv.net), drop `use flake` into `.envrc`. ## How it works `main.go` resolves the current `latest--nixos-` Elasticsearch alias, POSTs a query shaped like the one search.nixos.org sends, then renders each hit and hands them to `fzf` with a per-package preview file. Credentials are the same public ones the web frontend uses.