Import nix package from github that relies on git

Hi,

I’m trying to import a nix package from github into my shell, eg:

let
  package-src = fetchFromGitHub;
  package = import (package-src + "/default.nix");
in
mkShell {
  buildInputs = [
   package.program-dev
  ]
}

Sadly, that package uses git to calculate a version and looks like what fetchfromgithub fetches does not have the .git folder and so I get the error: “fatal: not a git repository (or any of the parent directories): .git”

Is there any way around this and keeping the same git version?
I can get around it by faking the version:

    (package.program-dev.overrideAttrs (oldAttrs: rec {
      version = "ebcb";
    }))

I guess this works fine for now:

    (package.program-dev.overrideAttrs (oldAttrs: rec {
      version = builtins.substring 0 8 package-src.rev;
    }))

So I get the same exact version which is probably fine I guess.

3 Likes