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.registryyou 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 nameselfis reserved. At the same time I can exportlegacyPackageswith all my local overlays from theselfflake 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 updatein 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 therevto the revision of the nixpkgs that the system was built from. -
The global flakes registry can be configured in
nix.confand 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/nullalso doesn’t work because a special JSON format is expected. To this end I just use the local registry located at/etc/nix/registry.jsonagain. Now all entries in my registry are duplicate but at least the global registry is gone.