Fetchgit hash mismatch with qmk_firmware + submodules

I’m having issues with fetchgit blaming hash mismatches depending on which machine I build the derivation. The Git repository in question is qmk/qmk_firmware. It contains a lot of submodules and furthermore I need to keep the .git directory (which AFAIK is the default with fetchSubmodules = true).

error: hash mismatch in fixed-output derivation '/nix/store/mxj028mz12r73p4zpiqc5r4y2j90l6qx-qmk_firmware.drv':
         specified: sha256-jr9rGec3i2fEgmnWHpxVe29zEVI6WmyhYZ7jwvRfKfg=
            got:    sha256-MY2vmMQKfqIQubC2QeAPIxS41e6dN4Gt8kyEIrY8SI0=

I tried different refs like commit-ids and lastly tags when I stumbled upon the comments in the source code of fetchgit.

I create the hash using lib.fakeHash and insert it into the code. Now, if try to build the derivation on a different machine, it will fail with a hash mismatch.

I don’t know to fix this. Any ideas what makes fetchgit fail in this case and how to fix it? Obviously fetchgit is not reproducible in this case.

I created a minimal reproducible example (flake based) for my problem (deleted) which can be easily git cloned. Just use nix build .#default.

Thanks

I tried doing the same thing to fetch qmk_firmware a while ago and IIRC, the cause of the hash mismatch is that the contents of the .git directory are not deterministic.

Unfortunately, I do not think this can be solved, although I would love to be proven wrong.

Edit: Apparently, there’s an issue about it in the nixpkgs repo that’s been open since 2015. `fetchgit` with `leaveDotGit = true` is still not completely deterministic · Issue #8567 · NixOS/nixpkgs · GitHub

1 Like

Thank you so much for your reply. It is now clear to me that it is not my fault and I’m not alone. This issue also explains that one cannot find good recipes for inspiration via $SEARCH_ENGINE. I changed my repo to use Just to avoid retyping all the options of qmk.