Introducing NUR - the Nix User Repostory || Share all your nix expressions!

To make sharing of nix packages easier and more decentralized I created NUR - the Nix User Repository.
It is a meta-repository, where contributor can add there own repositories to share nix expressions.

Checkout the examples in the documentation on how to use it:

In a nutshell it expose user contributed packages through namespace nur.repos.reponame
in e.x.:

$ nix-shell -p nur.repos.mic92.inxi
16 Likes

Wow amazing. I was conceptualising exactly this yesterday when @zimbatm mentioned this project. Perfect!

Just to understand, what’s the advantage of this over users hosting their own repos? The main thing I can think of would be that it is easier to grep through a single repo.

It’s an index of repositories that follow some conventions. This is entirely about making it easier to find stuff. In the works is the plumbing and then the interface to have a search interface through all indexed repositories.

It also has some minor advantages, where a repository’s commit won’t advance if it doesn’t evaluate.

In practice, every repositories found in the NUR would always work without using them through the NUR.

Hi,

So if I understand that correctly, I can also share functions I wrote
via this? For example, I have some functions which can be used to
modify packages in certain ways - I can share them here, too?

On another side: How can I bake this into my NixOS installation? So
that I can use NUR in my configuration.nix, essentially?

(Note that I’m on a sabatical and may respond slowly)

You can add it like this:

{
  nixpkgs.config.packageOverrides = pkgs: {
    nur = pkgs.callPackage (import (builtins.fetchGit {
      url = "https://github.com/nix-community/NUR";
    })) {};
  };
}

And yeah, in your repo you can put anything you’d like to share with the world, doesn’t matter if it’s functions or derivations. :slight_smile:

We would like to add namespaces in each repository for modules, functions and overlays so they are discoverable by search engines. I hope I can re-add documentation for this soon.

NUR seems to be pretty much what AUR is for Arch Linux, just with a couple added bonuses, in that it can also contain functions or similar things.

While I like the idea of having these repositories easily discoverable, I do not like the idea of directly using them on my system due to the security implications. So any kind of search engine or even an automatically created list would be very appreciated.

Yes, a search is definitely on the TODO list. To make review easier we tried to expose the owner directly, as it is often easier to trust a person then a package. Pinning could also be more convenient then copying the expression over. AUR also suffered lately from orphaned packages that were taken over by a malicious account - that is hopefully be more transparent in NUR.

1 Like

So circling back to this now that I’m actually using NixOS a bit more, and not just nixpkgs:

I think it would be a great special case of this to be the “docker hub” of nix containers, though I’d welcome others’ thoughts on this before diving in.

Suppose I have a repo for a specific purpose (for example, pro audio). Should I name it as suhr.audio in NUR?

To that point our repository hierachy is flat and for future tooling it might be easier if it stays that way. You could also create & add mutiple repositories.

How do I configure Travis for a NUR repo so it doesn’t fail on unfree packages?

That should work:

$ mkdir -p ~/.config/nixpkgs
$ echo '{ allowUnfree = true; }' > ~/.config/nixpkgs/config.nix
1 Like

Also setting the env variable NIXPKGS_ALLOW_UNFREE=1 does the same. Or if you do not want to build them you could filter them out like it’s done with broken packages here: https://github.com/nix-community/nur-packages-template/blob/c145cf0a48635e01dc11823b27ab936a7ab239ab/non-broken.nix

How do I use cachix for my NUR repo?

I have not actually tested it, but @fgaz added some example travis ci code for that: https://github.com/nix-community/nur-packages-template/blob/c145cf0a48635e01dc11823b27ab936a7ab239ab/.travis.yml#L31

1 Like

Should I just set CACHIX_CACHE=suhr or I also have to set the Cachix token somehow?

UPDATE: it finds out you indeed have to set the token.

So this is how you use Cachix:

  1. cachix derivative in nixpkgs is broken, so you have to replace nix-env -i cachix with nix-env -iA cachix -f https://cachix.org/api/v1/install in .travis.yml
  2. Set CACHIX_CACHE to the cache name
  3. Set the private variable CACHIX_SIGNING_KEY in the Travis settings. The value of this variable is the value of secretKey in .config/cachix/cachix.dhall
2 Likes