Skip to content

Commit

Permalink
WIP: support git submodules for flakes
Browse files Browse the repository at this point in the history
I want git submodules badly, so here is my equally bad attempt on adding
support for them in flakes.

TODO:
- This now unconditionally adds submodules for all flake inputs. Do we
  want that?
- This currently makes it equivalent to appending `?submodules=1` to the
  url. Do we want that?
- Figure out how this can be done for `self`.
- Add a test for the behaviour

Fixes: NixOS#4357
  • Loading branch information
knedlsepp committed Jan 3, 2021
1 parent 8a2ce0f commit 85daa5d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/libexpr/flake/flakeref.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(

if (pathExists(flakeRoot + "/.git/shallow"))
parsedURL.query.insert_or_assign("shallow", "1");
parsedURL.query.insert_or_assign("submodule", "1"); // TODO: Base this on a condition

return std::make_pair(
FlakeRef(Input::fromURL(parsedURL), get(parsedURL.query, "dir").value_or("")),
Expand Down
2 changes: 2 additions & 0 deletions src/libfetchers/git.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ struct GitInputScheme : InputScheme
attrs.emplace(name, value);
else if (name == "shallow")
attrs.emplace(name, Explicit<bool> { value == "1" });
else if (name == "submodules")
attrs.emplace(name, Explicit<bool> { value == "1" });
else
url2.query.emplace(name, value);
}
Expand Down

0 comments on commit 85daa5d

Please sign in to comment.