Speeding up NixOS package search on the terminal

Hello there! I noticed that there is a slight aversion to using nix search and recommending the NixOS package search or MyNixOS instead. So I wrote up a quick post on making it usable (or at least bearable) for searching packages for NixOS (or home-manager).

https://www.foodogsquared.one/posts/2023-11-10-speeding-up-nixos-package-search-on-the-terminal/

4 Likes

Quick feedback: the very first video doesn’t play.

Images don’t seem to load either:

What browser (and its version) are you using? I suspect those issues are due to missing support for codecs and image formats. The images are originally using AVIF but I can change them to WebP format. (Though, I’m not sure what’s exactly happening with the video.)

Mobile Safari (wrapped in Firefox but doesn’t make a difference). I’m on iOS 17.1.1 which is the latest version right now, not sure what Safari version that corresponds to.

I’ve been meaning to figure out how to make nix run use the system flake’s version to speed things up a bit, so seeing this posted here yesterday was a nice surprise! However, I had some trouble getting things to work. At first I tried to add this to the modules list of my system flake:

({ config, lib, ... }: { nix.registry = lib.attrsets.removeAttrs inputs [ "self" ]; })

(Aside: I don’t know if this is a problem with my system, but I had to use lib.attrsets.removeAttrs or builtins.removeAttrs instead of lib.removeAttrs which didn’t seem to exist. Maybe a difference between stable and unstable?)
The code above resulted in an error:

error: The option `nix.registry.agenix._type' does not exist. Definition values:
       - In `/nix/store/3s69yxbbl116zwga3i6cy7prplywq0bn-source/flake.nix': "flake"

I simplified the case down to

{ nix.registry.nixpkgs = nixpkgs; }

to avoid dealing with other inputs and any attribute set manipulation issues at first. It caused a similar error, though. After some googling, I ended up trying

{ nix.registry.nixpkgs.flake = nixpkgs; }

which worked. (Note the .flake in the attribute path.) Consulting documentation for nix.registry talks about nix.registry.<name>.flake too.

While I was writing this message, I took another look at the more advanced example near the end of the post. I had to do some repl checking to understand it better, but it seems like the inherit flake part handles the last part of the attribute path there? I’m not too experienced with Nix/NixOS yet, but is it possible the earlier code examples are just missing the .flake or is there something weird going on with my system?

Also, FWIW, the images and the video clip worked for me, on Firefox for macOS and Linux.

I changed the assets to support the most common formats. Hopefully this should fix it. (Though I should really handle the asset with automation, I’ve been handling them manually.)

Nope, that’s just a mistake on my part I forgot to update after testing the config. Good catch!

I forgot to update that part, too. You’re right about that, the earlier code examples are missing .flake which causes the error with the missing _type you described earlier. That’s a massive blunder on my part. I apologize for not checking the post thoroughly and thank you so much for the feedback.

Cool! The video was indeed fixed. The URL of the other images might have a typo, though?

Sorry, I didn’t immediately saw this. It’s just a bug from one of the site components. In the meantime, I also updated the site to have some crude automation for exporting them (which is long overdue) so that it can use both AVIF and WebP if your browser supports either of them. Now, it should have enough support for the major browsers.

Hmm it still doesn’t display properly, it actually looks the same now as before:

Why not use PNG? Genuine question, I don’t know much about these new formats.

1 Like