@@ -51,13 +51,15 @@ let
53 lines = s: filter (x : x != [] && x != "") (split "\n" s);
53 lines = s: filter (x : x != [] && x != "") (split "\n" s);
55+ origSrcSubDir = toString (src.origSrcSubDir or src);
56−if builtins.pathExists (toString src + "/.git")
58+if builtins.pathExists (origSrcSubDir + "/.git")
59− hasIndex = builtins.pathExists (toString src + "/.git/index");
61+ hasIndex = builtins.pathExists (origSrcSubDir + "/.git/index");
60− isWorktree = (builtins.readDir (toString src)).".git" == "regular";
62+ isWorktree = (builtins.readDir origSrcSubDir).".git" == "regular";
62 # Identify the .git directory and filter just the files that we need.
64 # Identify the .git directory and filter just the files that we need.
63 gitDir = cleanSourceWith ({
65 gitDir = cleanSourceWith ({
@@ -74,19 +76,19 @@ then
74 if hasIndex
76 if hasIndex
75 then { inherit src; subDir = ".git"; }
77 then { inherit src; subDir = ".git"; }
76 else if !isWorktree
78 else if !isWorktree
77− then abort "cleanGit: ${toString src + "/.git"} has no index file"
79+ then abort "cleanGit: ${origSrcSubDir + "/.git"} has no index file"
79 # likely a git worktree, so follow the indirection
81 # likely a git worktree, so follow the indirection
82− git_content = lines (readFile (toString src + "/.git"));
84+ git_content = lines (readFile (origSrcSubDir + "/.git"));
83 first_line = head git_content;
85 first_line = head git_content;
84 prefix = "gitdir: ";
86 prefix = "gitdir: ";
85 ok = length git_content == 1 && has_prefix prefix first_line;
87 ok = length git_content == 1 && has_prefix prefix first_line;
88 then /. + remove_prefix prefix first_line
90 then /. + remove_prefix prefix first_line
89− else abort "gitSource.nix: Cannot parse ${toString src + "/.git"}";
91+ else abort "gitSource.nix: Cannot parse ${origSrcSubDir + "/.git"}";
92 # Worktrees have a commondir pointing to the common `.git` dir. We need the
94 # Worktrees have a commondir pointing to the common `.git` dir. We need the
@@ -102,7 +104,7 @@ then
102 else gitDir + "/config";
104 else gitDir + "/config";
104 # We need the .gitmodules file for submoules to work.
106 # We need the .gitmodules file for submoules to work.
105− gitModulesStr = toString src + "/.gitmodules";
107+ gitModulesStr = origSrcSubDir + "/.gitmodules";
106 gitModules = builtins.path { name = "gitmodules"; path = gitModulesStr; };
108 gitModules = builtins.path { name = "gitmodules"; path = gitModulesStr; };
108 gitSubmoduleFiles = cleanSourceWith {
110 gitSubmoduleFiles = cleanSourceWith {
@@ -154,7 +156,7 @@ then
157− trace "gitSource.nix: ${toString src} does not seem to be a git repository,\nassuming it is a clean checkout." (
159+ trace "gitSource.nix: ${origSrcSubDir} does not seem to be a git repository,\nassuming it is a clean checkout." (
158 cleanSourceWith {
160 cleanSourceWith {
159 caller = "cleanGit";
161 caller = "cleanGit";
160 inherit name src subDir;
162 inherit name src subDir;