Using local nixpkgs

builtins.fetchGit initializes a headless git repository in ~/.cache/nix, clones the url passed to it and then pulls a checkout from it into /nix/store for use. I have a local nixpkgs clone and a lot of builtins.fetchGit. Because of that the git repo in .cache is taking up an additional 1GB. Is it possible to specify a local nixpkgs from which nix can pull out snapshots and use them.

One hackish way that I can think of is to move the whole .git directory of my clone to ~/.cache/nix, make it headless and somehow setup git to use that repo for a directory. Has anyone done something like that?

github has the option to fetch the revision as a tarball FAQ/Pinning Nixpkgs - NixOS Wiki

to manage a git repository from another directory, you’ll probably want to look at git worktree

1 Like