Sudo nixos-rebuild switch not a git repository

Running sudo nixos-rebuild switch gives the following error:

warning: Not a git repository. Use --no-index to compare two paths outside a working tree
error: program 'git' failed with exit code 129
   ... while fetching the input 'git+file:///path/to/nixos-configuration'

/path/to/nixos-configuration indeeds exists and is a git repository

Apologies. I just found git 2.35.2 breaks nixos-rebuild with flake repo owned by non-root user · Issue #169193 · NixOS/nixpkgs · GitHub

Hosted by Flying Circus.