Nix flakes and submodules

Hello,

I am playing with flakes new feture. I am testing on one project. This project has git submodules with “my tipical cmake scripts”. My nix flake is:

{                                                                                                                                                                                        
  description = "My lib";                                                                                                                                        
                                                                                                                                                                                         
  outputs = { self, nixpkgs }: {                                                                                                                                                         
                                                                                                                                                                                         
    defaultPackage.x86_64-linux =                                                                                                                                                        
    with import nixpkgs { system = "x86_64-linux"; };                                                                                                                                    
    stdenv.mkDerivation {                                                                                                                                                                
      name = "my_lib";                                                                                                                                                                     
      version = "0.1.0";                                                                                                                                                                 
      src = self;                                                                                                                                                                        
                                                                                                                                                                                         
      outputs = [ "out" "dev" ];                                                                                                                                                         
                                                                                                                                                                                         
      nativeBuildInputs = [ cmake ];                                                                                                                                                  
      buildInputs = [                                                                                                                                                                    
        spdlog                                                                                                                                                                           
        fmt                                                                                                                                                                              
        nlohmann_json                                                                                                                                                                    
        doctest                                                                                                                                                                          
      ];                                                                                                                                                                                 
    };                                                                                                                                                                                   
  };                                                                                                                                                                                     
}  

I get this error:

nix build -v                                                                                                                                                                 !10342
warning: Git tree '/home/eduardo/dev/clit' is dirty
building '/nix/store/y8pbpdnx50cy14i05irbbmy13wkxnv06-clit.drv'...
builder for '/nix/store/y8pbpdnx50cy14i05irbbmy13wkxnv06-clit.drv' failed with exit code 1; last 10 log lines:
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  CMake Error at CMakeLists.txt:16 (include):
    include could not find load file:
  
      GenericProject
  
  
  -- Configuring incomplete, errors occurred!
  See also "/build/source/build/CMakeFiles/CMakeOutput.log".
error: build of '/nix/store/y8pbpdnx50cy14i05irbbmy13wkxnv06-clit.drv' failed

The problem is that build cannot find the file GenericProject.cmake that is in the submodule. How can i get this working?

While nix gained the feature to include submodules on a builtins.fetchGit in https://github.com/NixOS/nix/pull/3166, we’ll need to wait for the next release to actually make use of it. (Or you install unstable nix)

Edit: Oops. I just realized you are using nix from the flakes branch. Hm. Might be a different issue then.

I see on the pull request that by default submodules is disabled. There is any way to configure something like this:

 src= {url= self; submodules=true;};