Skip to content

Submodules of flakes are not working #6633

@faulesocke

Description

@faulesocke

Describe the bug
Having git submodules in a git repository I cannot access the submodules in my flake.nix. This is especially annoying when I want to provide a flake.nix for software that is split across multiple git repositories that are all included as submodules in one main repo.

Steps To Reproduce

git init top
git init sub

cd sub/
echo "foobar" > foobar
git add foobar && git commit -m foobar
cd ..

cd top/
git submodule add ../sub sub
git commit -m submodules
git add flake.nix

And top/flake.nix is

{
  outputs = { self, nixpkgs }:
  with import nixpkgs { system = "x86_64-linux"; };
  {
    defaultPackage.x86_64-linux = stdenv.mkDerivation {
      name = "foobar";
      src = self;
      installPhase = ''
        cat sub/foobar > $out
      '';
    };
  };
}

Then run nix build.

Expected behavior
I expect result to contain the string foobar.

Actual behaviour

% nix build
warning: Git tree '/tmp/top' is dirty
error: builder for '/nix/store/wlxmp43q9q13477yjc2hvzqja8ng3sgf-foobar.drv' failed with exit code 1;
       last 10 log lines:
       > unpacking sources
       > unpacking source archive /nix/store/kzsvnqmnjrpyvma444jaz3zv3kgry8az-source
       > source root is source
       > patching sources
       > configuring
       > no configure script, doing nothing
       > building
       > no Makefile, doing nothing
       > installing
       > cat: sub/foobar: No such file or directory
       For full logs, run 'nix log /nix/store/wlxmp43q9q13477yjc2hvzqja8ng3sgf-foobar.drv'.

nix-env --version output
nix-env (Nix) 2.8.1
I also tried 2.8.0 and 2.9.1. The submodule is just missing and I see no way to access it.

Additional context
Also manually adding the submodule as an input like so

{
  inputs.sub = {
    url = "./sub";
    flake = false;
  };
 ...
}

and then changing the src = self to src = sub in the outputs, just results in a weird error message instead of the submodule just working as it should:

% nix build
warning: Git tree '/tmp/top' is dirty
error (ignored): error: end of string reached
error: getting status of '/nix/store/ms70asysgv7alri3972wpzpd4r6ivbiz-source/sub': No such file or directory
(use '--show-trace' to show detailed location information)

Especially the error (ignored): error: end of string reached line is worrying me and probably show that this is actually a bug and should work. Of course this could also just be my own stupidity and I'm doing something completely wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions