Invalid data in git index while nix flaek update

After doing a git reset to a commit that I know would build without problems, I get the following error:

; nix flake update                                                                                                            # zsh 
       … while fetching the input 'git+file:///home/me/src/my-nixos-conf'

       error: getting working directory status: invalid data in index - calculated checksum does not match expected

Worringly I get the same error on a fresh clone of the same repo Paki / My Nixos Conf · GitLab

Ok my fault for trusting β software like nix-super…

I don’t know what your nix-super is, but I accidentally ran into this when using fleek.

I have a working git repo holding my flake that’s already in the local store. I reset one file to what it was in a prior commit and then create a new commit with the result, and my nix flake update is now throwing this same error.

    .. while fetching the input 'git+file:///home/{username}/.local/share/fleek'
    error: getting working directory status: invalid data in index - calculatedd checksum does not match expected

I’ve tried deleting the repo and recloning it from the remote, but it doesn’t help. I’ve also tried resetting back to the commit that originally worked, and I still get the error. Nothing I do will let me get past the error, it doesn’t even seem to be related to the contents of the local repo anymore.

Is there some way to track down what nix store item was added for the local flake and forcibly remove it from the store? I assume that’s the fix here.

Ah, I just found nix store verify is even giving the same error. So somehow the flake being added to the store in the first place is what corrupted the nix store.

FYI: I’m on nix 2.20.3, and I’m using git 2.43.0

Now, after a complete uninstall and re-install of nix, I built my flake once, changed a file in the git repo, commited the change, and tried to rebuild it. And it caused the error.

When the error occurs, it doesn’t seem to be resolvable in any way short of completely uninstalling and re-installiung nix.

@aaravchen I also encountered the same problem.

TL;DR quick fix: cd ~/.local/share/fleek; git config --local index.skipHash false; git reset --mixed

after that things start working again normally!

It should soon become a thing of the past, once libgit2 updates propagate: