`deepClone` in `fetchgit` does not actually yield a deep clone

A python project I’m building uses setuptools-scm to set the version - this requires the full git history including tags. I tried to use fetchgit with the deepClone = true option, but this still results in a shallow clone. Here’s the derivation:

  pkgs = import <nixpkgs> { };
  renku = import (pkgs.fetchgit {
    url = "https://github.com/swissdatasciencecenter/renku-python";
    rev = "refs/heads/nix";
    deepClone = true;
    sha256 = "0hlrnyym2ifivdczmy17r5ipyrs25ay0zr576wc4n283azccbkj5";
  }) { } ;
in with pkgs;
  mkShell {
    pname = "renku";
    version = "0.16.0";
    buildInputs = [ renku ];
    nativeBuildInputs = [ git ];

and git log in the cloned directory:

$ git log                                                                                                                                                                                    /nix/store/45c1gh021h74sy8372kswdxyihf5z3r4-renku-python
commit 64afd8a31264e22c511c328f9392b6dc360ce1da (grafted, HEAD -> fetchgit)
Author: Rok Roškar <rok.roskar@example.com>
Date:   Wed Sep 15 02:05:03 2021 +0200

    chore: simplify nix build

Is there some other way that deepClone is supposed to be passed to fetchgit? Or has it been silently deprecated? I know there are many discussions about the downsides of leaveDotGit and deepClone because of unstable .git contents.

Typically we set


so it will use the version we say it is.

right - but I can’t do that. I need to be able to use the correct version. In addition, fetchgit (because it actually does a shallow clone) makes the repo dirty which causes additional headaches. Is there no way to simply get the equivalent of

git clone <url>
git checkout <ref>

When using pbr, try:


Support for deepClone was silently broken in nix-prefetch-git: don't fetch everything when given a hash by Atemu · Pull Request #130040 · NixOS/nixpkgs · GitHub, and not reverted or fixed. Having come across this myself though, I opened `fetchgit`: don't shallow clone if `deepClone` is requested by infinisil · Pull Request #252865 · NixOS/nixpkgs · GitHub to fix it!

1 Like