Searching nix packages
Hey !!
I'm so happy you made this plugin. I previously tried to contribute a nix backend but the PR got rejected. So happy that it is possible now using plugins.
On searching packages, this plugin assumes people already have nix installed, right ? If so, there are nix executables (either run directly by nix run or installable with your plugin) that can help people find packages from the comfort of their terminal:
nix-versions - I made this tool to search on several backends (nixhub is one of them). It also provides other features like a flake generator for pinned versions (see the website). It also allows searching by provided binary.
Anyways there it is, if you find it useful maybe we can have a reference to it on readme.
I just found this tool the other day. Will give a crack at integrating it. Can your tool support this issue: https://github.com/jbadeau/mise-nix/issues/2
Currently it does not filters by system, not all backends provide that information, I nixhub is one that does,
but currently we are not using that to filter by platform: https://github.com/vic/ntv/blob/main/packages/backends/nixhub/nixhub.go#L47
maybe you can send a PR or implement your own search that just hits on nixhub, my old PR did filter using the user platform, so I know the metadata is returned by nixhub, you would need to filter by it.
curl -v 'https://search.devbox.sh/v2/pkg?name=emacs' | jq | bat
try running that and you will see all info there to filter by platform.
If you need to obtain the user's system you can do:
nix-instantiate --eval --expr --raw 'builtins.currentSystem'
and then use that to filter the json results from nixhub. (devbox.sh)
I added support for platforms but I’m not happy with the string parsing. Will have a go at making a Mr to nix-versions. I’m just astounded that this metadata is so hard to get