Derivations that depend on Git Submodules

Hi. This is my first attempt at building a derivation to install a package.

The Github repo that contains the source has a submodule but according to the error, it looks like it’s trying to use the same rev for both the base repo and its submodule.
So I’m pulling in a repo called bld with the rev a8d2310f8493200d7d776bc542fa0233a6eb4d0f and the error is as it’s trying to use that as the rev for its submodule rife2-core.

Am I misusing fetchGit?

This is what I have so far:

  pkgs ? import (fetchTarball {
    url = "";
    sha256 = "sha256:06jzngg5jm1f81sc4xfskvvgjy5bblz51xpl788mnps1wrkykfhp";
  }) {}
pkgs.stdenv.mkDerivation rec {
  pname = "bld";
  version = "1.9.1";

  src = fetchGit {
    url = "";
    ref  = "main";
    rev = "accf27c4db3ba3c15eeb481469ef4cc740da498d";
    submodules = true;

  buildInputs = [
  configurePhase = ''
  installPhase = ''
    ls -al
    ./bld compile

Where the error is
error: Cannot find Git revision 'a8d2310f8493200d7d776bc542fa0233a6eb4d0f' in ref 'master' of repository ''! Please make sure that the rev exists on the ref you've specified or add allRefs = true; to fetchGit.

In general you’ll want to use one of the fetchers from nixpkgs, not builtin fetchers like fetchGit.

In this case, fetchFromGitHub will work, though then you run into another (known issue) that submodules with SSH urls are kinda broken, though for that you can use this workaround to force HTTPS instead. Finally, set hash to the empty string ("") and you get the actual hash from the resulting error.

This would result in your src being set to the following (before replacing the hash):

(pkgs.fetchFromGitHub {
  owner = "rife2";
  repo = "bld";
  rev = "accf27c4db3ba3c15eeb481469ef4cc740da498d";
  fetchSubmodules = true;
  hash = "";
}).overrideAttrs {
  GIT_CONFIG_KEY_0 = "url.";