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 try on adding
support for them.

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.
I need to figure out how this can be done for `self`.

Fixes: NixOS#4357
  • Loading branch information
knedlsepp committed Jan 3, 2021
1 parent 8a2ce0f commit d489f8e
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 d489f8e

Please sign in to comment.