Sharing private derivations/overlays

I wrote shell.nix files for a couple projects at work – a front-end Vue app and a back-end Rails API it works with – using mkShell so we can easily spin up their dev environments.

We have an internal CLI (built and maintained in-house) that’s useful for deploying our apps. I wrote a Nix derivation for it so I could install it on NixOS.

It would be nice if our apps’ dev environments included the CLI.

The derivation currently lives in an overlay in my nixos config, so I need to give it a proper home.
There are three approaches I can think of:

  1. Add the CLI derivation to the CLI’s own repo.
  2. Create a repo for in-house overlays (similar to nixpkgs-mozilla).
  3. Create a fork of nixpkgs to hold our in-house derivations.

Option 1 is appealing because it seems simple. I suspect it would also make it easy to spin up a dev environment for the CLI itself when we want to hack on that.

Option 2 would provide a central location for in-house Nix derivations, but I’m not sure that makes sense given that I’m already putting shell.nix files directly in the other projects. Of course, in those projects the aim was to spin up a dev environment, rather than to provide an installable package, so maybe there’s a hybrid approach that makes sense. I do like overlays…

Option 3 seems simple in some ways, but I don’t like the idea of maintaining a fork of nixpkgs. I could be wrong, but my gut tells me this would be an unpleasant approach.

What do you think would be a good solution?

I’d add it to the CLI’s repo and some simple documentation for using nix. Then anyone in your organization that wants to try it out can build it with nix without having to worry about other dependencies for the app using nix-build, and if anyone wants to develop the CLI app, they can use nix-shell to create an environment with all the dependencies need to build it. Overlays are a better use case for a collection of apps you want to pin to specific version. For example, later on if you decide you want to package your Vue app, rails app and CLI app tagged at stable versions you want to share with your customers (external or internal to your organization).



1 Like