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 !
24 Likes
bew
January 15, 2024, 1:30pm
2
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
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…
cab
January 23, 2024, 6:59pm
9
do you want some top-level subdomain *.nix.moe for this?
Such logic can also be hosted on Cloudflare for free though
2 Likes
I assume the domain requires a subscription.
I recently added a new endpoint: /channel/:channel
It gives you a slightly nicer way of using the channels.nixos.org tarballs (which are a good bit smaller than the GitHub equivalents) in your Flakes, like this:
{
inputs.nixpkgs.url = "https://nixpkgs.dev/channel/nixos-unstable";
}
And thanks to @emilylange for originally adding support for this upstream in mirror-nixos-branch: add header for "Lockable HTTP Tarball Protocol" (Flakes) by emilylange · Pull Request #76 · NixOS/nixos-channel-scripts · GitHub
6 Likes