Support building flakes from a shallow Git repo

Fixes #3756.
This commit is contained in:
Eelco Dolstra 2020-07-01 14:57:59 +02:00
parent 26cf0c674f
commit 7d554f295c
2 changed files with 5 additions and 0 deletions

View file

@ -142,6 +142,9 @@ std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
parsedURL.query.insert_or_assign("dir", subdir);
}
if (pathExists(flakeRoot + "/.git/shallow"))
parsedURL.query.insert_or_assign("shallow", "1");
return std::make_pair(
FlakeRef(Input::fromURL(parsedURL), get(parsedURL.query, "dir").value_or("")),
fragment);

View file

@ -42,6 +42,8 @@ struct GitInputScheme : InputScheme
for (auto &[name, value] : url.query) {
if (name == "rev" || name == "ref")
attrs.emplace(name, value);
else if (name == "shallow")
attrs.emplace(name, Explicit<bool> { value == "1" });
else
url2.query.emplace(name, value);
}