Nix flake commands fail for shallow Git repositories

If I run a command such as nix run, nix flake update, etc. I get the following error:

error:
       … while fetching the input 'git+file:///<redacted>'

       error: '/<redacted>' is a shallow Git repository, but shallow repositories are only allowed when `shallow = true;` is specified.

I’ve tried adding shallow = true; to the flake.nix but it’s an unsupported attribute. Neither the error text nor Google searching provide any clues to where I’m supposed to specify shallow = true.

This isn’t documented very clearly, but reading between the lines the git type parameters appear to refer to arguments of fetchGit: Built-in Functions - Nix Reference Manual

So if my reading is correct, you would append ?shallow=true to the URL.

This is a guess, never had to do this before myself and I’m far too lazy to dig through the source to confirm this right now.

Appending ?shallow=true did not work, but ?shallow=1 did (syntax found in this nix Github issue)

1 Like