Skip to content

Commit e02f01e

Browse files
authored
Improve the way sha256map works (#1967)
* Improve the way `sha256map` works This change makes it so `sha256map = null` and `sha256map = {}` work the same. When looking up a sha256 in the map it will only now fail if the map contains an entry for the url, but not for the tag required. * Update stack-cache-generator as well
1 parent 9449cc4 commit e02f01e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/cabal-project-parser.nix

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ let
8484
url = repo.location;
8585
"${refOrRev}" = repo.tag;
8686
sha256 = repo."--sha256" or (
87-
if sha256map != null
88-
then sha256map."${repo.location}"."${repo.tag}"
87+
if sha256map != null && sha256map ? ${repo.location}
88+
then sha256map.${repo.location}.${repo.tag}
8989
else null);
9090
subdirs = if repo ? subdir
9191
then pkgs.lib.filter (x: x != "") (pkgs.lib.splitString " " repo.subdir)
@@ -136,7 +136,7 @@ let
136136
attrs = parseBlockLines x.fst;
137137
sha256 = attrs."--sha256" or (
138138
if sha256map != null
139-
then sha256map."${attrs.url}"
139+
then sha256map.${attrs.url} or null
140140
else null);
141141
in rec {
142142
# This is `some-name` from the `repository some-name` line in the `cabal.project` file.

lib/stack-cache-generator.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ concatMap (dep:
8282
let
8383
is-private = private dep.url;
8484
sha256 =
85-
if dep.sha256 != null then dep.sha256
86-
else if sha256map != null then sha256map."${dep.url}"."${dep.rev}"
85+
if dep.sha256 != null
86+
then dep.sha256
87+
else if sha256map != null && sha256map ? ${dep.url}
88+
then sha256map.${dep.url}.${dep.rev}
8789
else null;
8890
branch = lookupBranch {
8991
location = dep.url;

0 commit comments

Comments
 (0)