Simplest way to install a few custom nix packages?

What is the simplest way you have found to install à la carte nix packages?

I’m wondering about the simplest way to install nix packages from a public URL.
I need to do so from a machine that has a single user nix install but is another GNU/Linux distribution.

I have read section 13 in the manual that discusses sharing packages between machines.

My network architecture prohibits opening port 22 between machines. I also remember feeling overwhelmed by the complexity of that approach. I’m hoping to find a simple way to install a nix expression that does not require network configuration or other architectural changes.

I’m curious about your experiences and approaches. From what I can tell, cachix and other recent projects I’ve seen announced try to fill this void. Thanks!

You want to install a set of packages from nixpkgs on multiple machines, is that right?

Have you considered home-manager?

With it you can declare the required packages in ~/.config/nixpkgs/home.nix, version control it and pull it from each machine. (You can do other cool stuff as well, it’s roughly like a configuration.nix for your user profile.)

1 Like

I am not 100% clear on whether you are looking for a way to use publicly-hosted expressions to build the software, or to re-use build artifacts via a publicly-accessible cache?

2 Likes

Yes. A more succinct way to state it!

I love the idea of home manager. I was scared away by the “Before attempting to use Home Manager please read the warning below.” in the README. I’m an application engineer squeaking by in operations. So I am being very conservative with what I am implementing for some production systems. That said, this fear could be imagined.

Good point! I am trying to package static binaries and have them be able to be installed from a Linux machine with a single user nix installation. So more “re-use build artifacts via a publicly-accessible cache”.

1 Like

The only real thing that I experienced, and which you get used to when working more often with nix anyway, is this:

Unfortunately, it is quite possible to get difficult to understand errors when working with Home Manager, such as infinite loops with no clear source reference.

The naturally correct recommendation follows immediately:

If you are not very familiar with Nix but still want to use Home Manager then you are strongly encouraged to start with a small and very simple configuration and gradually make it more elaborate as you learn.

I’d add here that your simple configuration should ideally start on top of a clean user environment, because the probability of home-manager trying to interfere with existing files gets reduced drastically. Although even that was never a problem to me in practice, since home-manager just tells you what happened, and you can usually move that file out of the way and incorporate what ever it’s doing into your configuration.

1 Like