Nixpkgs.dev: a link shortener for Nixpkgs

nixpkgs.dev is a small service that allows you to use short URLs when referring to a package or an option on NixOS Search! For instance, instead of sending https://search.nixos.org/packages?channel=unstable&show=comma, you can now send nixpkgs.dev/comma.

Here are the currently available routes:

  • /:package (defaults to unstable channel)
  • /:channel/:package
  • /option/:option (also defaults to unstable)
  • /option/:channel/:package

This project is open source on GitHub at ryanccn/nixpkgs-dev!

20 Likes

Looks nice ! Do you plan to add a ‘clic to copy short link’ button to search.nixos.org ?

Maybe we could request @qyliss a redirect from .gs :blush:

I already did via email!

1 Like

Wow, awesome! Is it possible to add e.g. position/:package which links to the 📦 Source on search.nixos.org, i.e. the meta.position of a package?

For example, position/comma can redirect to https://github.com/NixOS/nixpkgs/blob/c3e128f3c0ecc1fb04aef9f72b3dcc2f6cecf370/pkgs/tools/package-management/comma/default.nix#L38

I thought about adding this feature in the initial release, but there are various technical difficulties with adding such a feature:

  • Evaluating Nixpkgs is slow, so uncached meta.position queries would result in somewhat slow redirects
  • A separate traditional server backend would have to be added in order to call Nix directly
  • It might not be wise to rely on NixOS Search’s internal Elasticsearch instance since there might be breaking changes

Yeah, I was not thinking about evaluating nixpkgs, rather I was thinking about parsing the first result on search.nixos.org, and get the 📦 Source provided there. But as you have pointed out above, this would be an incredibly fragile operation… Indeed, better not to do it unless there is a stable API.

no thanks, if for any reason the service stops working, so will do your links…

do you want some top-level subdomain *.nix.moe for this? :slight_smile:

Such logic can also be hosted on Cloudflare for free though

1 Like

I assume the domain requires a subscription.