I’d like to address some points regarding the registry from your original post, because I have some workarounds for these problems. First of all I show the configuration for Nix:
# inputs are the flake inputs
{
nix = {
package = pkgs.nixFlakes;
registry = { # (1)
self.flake = inputs.self; # (2)
nixpkgs = {
from = {
id = "nixpkgs";
type = "indirect";
};
to = {
owner = "NixOS";
repo = "nixpkgs";
rev = inputs.nixpkgs.rev; # (3)
type = "github";
};
};
};
# (4)
extraOptions = ''
experimental-features = nix-command flakes ca-references
flake-registry = /etc/nix/registry.json
'';
};
}
-
Using
nix.registry
you can set entries in the local registry which is stored in/etc/nix/registry.json
. -
First I register the system configuration itself as a flake in the registry under the name
self
. This prevents me from accidentally using it as a flake input elsewhere because the nameself
is reserved. At the same time I can exportlegacyPackages
with all my local overlays from theself
flake and get instant Nix shells. -
I could do the same for nixpkgs, i.e.
nix.registry.nixpkgs.flake = inputs.nixpkgs;
, however, that would write the local store path to the registry and when I thennix flake update
in one of my other flakes it will write the store path into the lock file and others will not be able to build the flake anymore. Instead I just write the registry entry by hand but pin therev
to the revision of the nixpkgs that the system was built from. -
The global flakes registry can be configured in
nix.conf
and defaults to https://github.com/NixOS/flake-registry/raw/master/flake-registry.json. It accepts a URI or a local path. Unfortuantely, you can’t leave the field empty (flake-registry =
) and settings it to/dev/null
also doesn’t work because a special JSON format is expected. To this end I just use the local registry located at/etc/nix/registry.json
again. Now all entries in my registry are duplicate but at least the global registry is gone.