Setting up Private Nix registry or repo

Hello all, I am a (very) new user of Nix, mainly interested in it as Nix provides unified mechanism for outputting various package types (debian, python, docker images, appimages etc).

I am trying to setup something which would act like a privae registry / repository housing various flakes I will write. Is there anyway I can ask Nix to look at the flakes defined in this registry before it tries to look at any other registry? Sort of like primary and secondary PyPI indices.

For example:

Lets assume my private registry has following flakes defined:

  1. foo
  2. bar
  3. baz

When I run:

nix profile install foo#MAIN_PKG

Nix first looks at my registry, if it finds the flake with appropriate target, it uses it. If Nix is unable to find a match in my registry, it looks at the standard nix registries.

If you could point me to a very bare-bones example or better yet (if its simple/quick enough) show me how to implement this, I would really appreciate it.


I realise, I could simply use the absolute path to the flake like:

nix profile install /path/to/flake/parent/dir#MAIN_PKG

However, I dont want to pollute my scripts with absolute paths and would prefer a more configurable way.
As my planB, I could possibly have an ENV_VAR providing the path to the collection of flakes,
but I would prefer to avoid it if I can.


You can add flakes from git URLs or local directories to your user flake registry and give them nicknames. Check out nix registry --help.

nix registry add myshortname /path/to/flake

Then you can do

nix profile install myshortname#MAIN_PKG

On NixOS, you can set your nix registries declaratively. I haven’t tried with a local one, but probably something like this:

nix.registry.myshortname.flake = "/path/to/flake";
1 Like

Hello @noah , thanks for a quick reply. This actually works great! :smiley:

Let me be a bit more greedy and ask you for a slight modification on this.

Is it possible to have a registry behave like the nixpkgs repository in your example?

For instance, assuming I have a directory with following hierarchy:


Is there a possibility that I could add FLAKES as a registry as shown in your exmaple:

nix registry add /FLAKES

Having done this, how can I do the following?

nix flake show

nix profile install

Thanks a lot for sharing your insights! :smiley:

1 Like

Hey, good question. To be honest, I’m not sure if that’s possible to do natively. There might be a clever way to generate nix.registry.somesubdir registries programmatically, but I’m not so sure that’s the right approach.

Is it possible to have a registry behave like the nixpkgs repository in your example?

As far as I’m aware, the nixpkgs repository is not a collection of flakes. Instead, it’s a single flake with many outputs. That’s why you can run github:NixOS/nixpkgs#hello or any other package.

Similarly, I would recommend having a single flake with lots of outputs (devShells, packages, etc.) for each of your packages and projects. That way, the flake is what controls the “registry”, and each of the projects are available as outputs provided by the flake. So you would access them with nix profile install mypkgs#foo.

Hey @noah , thanks for the suggestions.

The way I am trying to approach this is, having a repository of flakes with each flake defining output packages, devShells etc tied to the applications.

For example, an application such as blender could be split as following different packages (however they are related) in a single flake:

  1. blender (main application)
  2. blender-docs (only documentation)
  3. blender-python (blender as a python module)
  4. cycles (render engine)
  5. blender-shell (a dev shell)

I really like the fact that flakes can show their outputs. So in this case, I could potentially do something like:

# Provide a visual representation of all the various outputs provided by Blender flake
nix flake show PKGS.blender`

# Also we can easily get the metadata for each flake trivially as follows:
nix flake metadata PKGS.blender

This becomes really difficult to achieve using a single flake, which would simply clutter the information.

I could actually use the registry method you showed earlier (specially since it actually does what I want to achieve), if this proves to be very convoluted to achieve.

Hey @bhaveshpandey, I see why you’d want to build that pattern instead of a single flake.

In that case, I would think about writing a small script that to find all of the directories that you want to include, and either load them into your registry with nix registry add commands, or generate a registry.json file with links that look like this:

  "flakes": [
      "from": {
        "id": "myflake",
        "type": "indirect"
      "to": {
        "path": "/path/to/my/flake",
        "type": "path"
  "version": 2

If you save that file to ~/config/nix/registry.json (or load that file in manually with nix registry add --registry ./config.json) then you should have those flakes available to your user profile.

1 Like