Skip to content

Commit 8bbf7dc

Browse files
committed
Determine if the tag is a ref or a rev
Test the `tag` attribute in the `cabal.project` file. If it looks like a git hash, then assign it to `rev`. Otherwise, assign it to `ref`.
1 parent 986a65b commit 8bbf7dc

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/cabal-project-parser.nix

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,15 @@ let
7474
# --shar256: 003lm3pm0000hbfmii7xcdd9v20000flxf7gdl2pyxia7p014i8z
7575
# will be trated like a field and returned here
7676
# (used in call-cabal-project-to-nix.nix to create a fixed-output derivation)
77-
extractSourceRepoPackageData = cabalProjectFileName: sha256map: repo: {
77+
extractSourceRepoPackageData = cabalProjectFileName: sha256map: repo:
78+
let
79+
refOrRev =
80+
if builtins.match "[0-9a-f](40)" repo.tag
81+
then "rev"
82+
else "ref";
83+
in {
7884
url = repo.location;
79-
ref = repo.tag;
85+
"${refOrRev}" = repo.tag;
8086
sha256 = repo."--sha256" or (
8187
if sha256map != null
8288
then sha256map."${repo.location}"."${repo.tag}"

lib/call-cabal-project-to-nix.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ let
228228
then throw "${inputMap.${repoData.url}.rev} may not match ${repoData.ref} for ${repoData.url} use \"${repoData.url}/${repoData.ref}\" as the inputMap key if ${repoData.ref} is a branch or tag that points to ${inputMap.${repoData.url}.rev}."
229229
else inputMap.${repoData.url})
230230
else if repoData.sha256 != null
231-
then fetchgit { inherit (repoData) url sha256; rev = repoData.ref; }
231+
then fetchgit repoData
232232
else
233233
let drv = builtins.fetchGit { inherit (repoData) url ref; };
234234
in __trace "WARNING: No sha256 found for source-repository-package ${repoData.url} ${repoData.ref} download may fail in restricted mode (hydra)"

0 commit comments

Comments
 (0)