SixFoisNeuf

Totally irregular blog on computers and security


Searching through nixpkgs and NixOS modules without Internet

Posted on Dec 7, 2023

I’ve converted to NixOS! It’s very cool, and I like it a lot. My main gripe is that looking up derivations or NixOS configuration options seems to very much depend on using https://search.nixos.org. The website is fine, but I don’t like that there’s no real alternative you can use directly from your terminal, short of manually grepping through your copy of nixpkgs.

All the raw data is here, so it was only a matter of writing wrappers around it. They’re in my nix-tools repository.

$ git clone https://git.sixfoisneuf.fr/nix-tools
$ cd nix-tools/
$ go build ./cmd/nix-search
$ go build ./cmd/nixos-search
  • nix-search works by parsing the output of nix-env -qa --json --meta to search through all available packages.
  • nixos-search works by using the nixosOptionsDoc.optionJSON derivation, which generates a JSON file with all the NixOS options

Most importantly, neither of the two tools require an Internet connection to work, either during normal usage or during indexing.

Send your comment via e-mail