Skip to content

Commit fe5041f

Browse files
ismaelbouyafbooniepepper
authored andcommitted
Add "branch" information for builtins.fetchGit (input-output-hk#1019)
The builtins.fetchGit used by haskell.nix clones only the subset of a repository corresponding to HEAD. So if we have a workflow that has a branch "development" as HEAD, but the stack.yaml only targets commits from "master", then it will be unable to fetch any commit. Fixes input-output-hk#592
1 parent 76239ee commit fe5041f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/stack-cache-generator.nix

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
if sha256map != null
1414
then { location, tag, ...}: sha256map."${location}"."${tag}"
1515
else _: null
16+
, branchMap ? null
17+
# A way to specify in which branch a git commit can
18+
# be found
19+
, lookupBranch ?
20+
if branchMap != null
21+
then { location, tag, ...}: branchMap."${location}"."${tag}" or null
22+
else _: null
1623
, resolverSha256 ? null
1724
, nix-tools ? pkgs.haskell-nix.internal-nix-tools # When building stack projects we use the internal nix-tools (compiled with a fixed GHC version)
1825
, ...
@@ -84,15 +91,19 @@ concatMap (dep:
8491
location = dep.url;
8592
tag = dep.rev;
8693
};
94+
branch = lookupBranch {
95+
location = dep.url;
96+
tag = dep.rev;
97+
};
8798
pkgsrc =
8899
if !is-private && sha256 != null
89100
then pkgs.fetchgit {
90101
inherit (dep) url rev;
91102
inherit sha256;
92103
}
93-
else builtins.fetchGit {
104+
else builtins.fetchGit ({
94105
inherit (dep) url rev;
95-
};
106+
} // pkgs.lib.optionalAttrs (branch != null) { ref = branch; });
96107
in map (subdir: {
97108
name = cabalName "${pkgsrc}/${subdir}";
98109
inherit (dep) url rev;

0 commit comments

Comments
 (0)