From 201cf5faf647fb12e1b14c41119ea8cb163502bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 25 Jan 2021 16:46:44 +0100 Subject: [PATCH] Add "branch" information for builtins.fetchGit This is the counterpart of nix-tools proposed change: https://github.com/input-output-hk/nix-tools/pull/99 --- lib/stack-cache-generator.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/stack-cache-generator.nix b/lib/stack-cache-generator.nix index 6c6f3e86fd..8756913ab5 100644 --- a/lib/stack-cache-generator.nix +++ b/lib/stack-cache-generator.nix @@ -13,6 +13,13 @@ if sha256map != null then { location, tag, ...}: sha256map."${location}"."${tag}" else _: null +, branchMap ? null + # A way to specify in which branch a git commit can + # be found +, lookupBranch ? + if branchMap != null + then { location, tag, ...}: branchMap."${location}"."${tag}" or null + else _: null , resolverSha256 ? null , nix-tools ? pkgs.haskell-nix.internal-nix-tools # When building stack projects we use the internal nix-tools (compiled with a fixed GHC version) , ... @@ -84,15 +91,19 @@ concatMap (dep: location = dep.url; tag = dep.rev; }; + branch = lookupBranch { + location = dep.url; + tag = dep.rev; + }; pkgsrc = if !is-private && sha256 != null then pkgs.fetchgit { inherit (dep) url rev; inherit sha256; } - else builtins.fetchGit { + else builtins.fetchGit ({ inherit (dep) url rev; - }; + } // pkgs.lib.optionalAttrs (branch != null) { ref = branch; }); in map (subdir: { name = cabalName "${pkgsrc}/${subdir}"; inherit (dep) url rev;