Why is there a clone of nixpkgs in the store?

I’m trying to figure out why my fish shell is trying to source $USER/.local/share/omf/fish.init, so for that reason I’m attempting to remove all references to oh-my-fish from within my nix store. There’s a store path named HASH-source that is mentioned in a store path HASH-etc-nix-registry.json that seems to be a clone of nixpkgs, and so naturally it contains multiple references to oh-my-fish.

Could someone give me an explanation of the internals of nix that make it necessary to have a clone of nixpkgs in the store? From the mention in HASH-etc-nix-registry.json, I’m thinking it might be related to flake inputs?

Not a thorough explanation, but I think indeed it’s related to the flake inputs. Since it shouldn’t matter whether you nix build a flake from a checked out clone or from a remote URL, the flake first needs to be “synthesized” from its inputs and “cached” locally, and also substitute flake-relative paths (e.g. occurrences of imports = [ ./some.nix ]), that can through the /nix/store mechanism now be substituted to reproducible absolute paths that are used during the actual build.

Maybe another way to look at it is as an “immutable cache” and possibly also the place where a flake or channel might result in the same store path if the same commit is referenced. Cool, since if you already have that commit of nixpkgs it won’t need to be downloaded again.

It seems to come from the nixos options nixpkgs.flake.setFlakeRegistry and nixpkgs.flake.source. The former by default sets the registry to point the “nixpkgs” registry entry to the latter, which is set to the nixpkgs flake path if you use the nixosSystem flake function. Point being, your registry will, by default, point to a copy of the exact version of nixpkgs you built your system with

Thank you for the answers!