this post was submitted on 13 Jul 2024
6 points (80.0% liked)

nixos

1262 readers
8 users here now

All about NixOS - https://nixos.org/

founded 4 years ago
 

Hoe do you self host a nix package repo & install nix packages from 3rd party repos? Is this even possible.

Other package managers allow you to install packages from 3rd party repos such as Flatpaks, apt, F-Droid, Scoop, Winget.

And is there any known 3rd party nix package repos?

all 7 comments
sorted by: hot top controversial new old
[–] [email protected] 6 points 3 months ago (1 children)

Generally you would use flakes to enable third party repos, although there are ways to do it without flakes. With flakes, third party repos work basicallly the same way as the main repo. Chaotic Nyx is one repo, and it also explains how to set it up. There's also ones like Nixified AI.

[–] [email protected] 1 points 2 months ago* (last edited 2 months ago)

To add to this, there's also Nix User Repository

[–] [email protected] 2 points 2 months ago* (last edited 2 months ago)

Hoe do you self host a nix package repo & install nix packages from 3rd party repos? Is this even possible.

So, one aspect of this has already been answered by @[email protected] . If you just want to package some stuff yourself, then do it (look at various NUR repositories for inspiration), put it in some git repo (or even a .tar.gz somewhere), and then fetch it from your NixOS config, either with flakes or þe olde way with let myPkgs = import (builtins.fetchGit { url = "https://..."; rev = ""; }) {}; in ....

Another aspect would be providing a substituter/"binary cache" for your repository, so that its users wouldn't need to build everything from source. This is a tad more complicated, as you have to set up some form of CI+CD, a place to host the cache, and your users would have to configure their systems to trust your build infrastructure.

It's all quite doable, and if you have some CI system&s3 bucket ready, boils down to nix copy $(nix build --print-out-paths) --to s3://your.hosting/your-cache with some authorization and error handling. There are also some readily available services that do it for you, like https://nixbuild.net, https://garnix.io, and https://cachix.io; however, be prepared to pay for the convenience.

Then, on the user end, you'd have to add extra-substituters = https://your.hosting/your-cache; extra-trusted-public-keys = <...> to ~/.config/nix/nix.conf, and it should all mostly work.

Examples of complex 3rd party repositories with a binary cache would be both aforementioned Chaotic and Nixified AI, and a more unusual haskell.nix.

[–] [email protected] -2 points 3 months ago (1 children)

No, i don't. And stop calling me a hoe!

[–] [email protected] 2 points 3 months ago (1 children)
[–] [email protected] 1 points 3 months ago

Thank you! Lol