Try to fetchGit the provided src
The goal is to filter the provided src tree based on Git tracked files to avoid unexpected rebuild. If the provided src tree is a not valid Git repository, no filtering is applied.
This commit is contained in:
parent
f012cc5092
commit
2c2a50af4d
15
default.nix
15
default.nix
|
@ -54,8 +54,19 @@ let
|
|||
assert flake.edition == 201909;
|
||||
outputs;
|
||||
|
||||
src' =
|
||||
(if src ? outPath then src else { outPath = src; })
|
||||
src' = let
|
||||
dir = builtins.readDir src;
|
||||
gitDir = builtins.readDir (src + "/.git");
|
||||
isGitDir = dir ? ".git" && dir.".git" == "directory";
|
||||
isNotShallow = ! gitDir ? "shallow";
|
||||
# Try to clean the source tree by using fetchGit, if this source
|
||||
# tree is a valid git repository.
|
||||
tryFetchGit = src:
|
||||
if isGitDir && isNotShallow
|
||||
then builtins.fetchGit src
|
||||
else { outPath = src; };
|
||||
in
|
||||
(if src ? outPath then src else tryFetchGit src)
|
||||
// { lastModified = 0; lastModifiedDate = formatSecondsSinceEpoch 0; };
|
||||
|
||||
# Format number of seconds in the Unix epoch as %Y%m%d%H%M%S.
|
||||
|
|
Loading…
Reference in a new issue