diff --git a/lib/cabal-project-parser.nix b/lib/cabal-project-parser.nix index 01672b90b9..0d93ba157b 100644 --- a/lib/cabal-project-parser.nix +++ b/lib/cabal-project-parser.nix @@ -74,9 +74,15 @@ let # --shar256: 003lm3pm0000hbfmii7xcdd9v20000flxf7gdl2pyxia7p014i8z # will be trated like a field and returned here # (used in call-cabal-project-to-nix.nix to create a fixed-output derivation) - extractSourceRepoPackageData = cabalProjectFileName: sha256map: repo: { + extractSourceRepoPackageData = cabalProjectFileName: sha256map: repo: + let + refOrRev = + if builtins.match "[0-9a-f](40)" repo.tag != null + then "rev" + else "ref"; + in { url = repo.location; - ref = repo.tag; + "${refOrRev}" = repo.tag; sha256 = repo."--sha256" or ( if sha256map != null then sha256map."${repo.location}"."${repo.tag}" diff --git a/lib/call-cabal-project-to-nix.nix b/lib/call-cabal-project-to-nix.nix index 1517574075..7ee2016dea 100644 --- a/lib/call-cabal-project-to-nix.nix +++ b/lib/call-cabal-project-to-nix.nix @@ -228,10 +228,10 @@ let 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}." else inputMap.${repoData.url}) else if repoData.sha256 != null - then fetchgit { inherit (repoData) url sha256; rev = repoData.ref; } + then fetchgit { inherit (repoData) url sha256; rev = repoData.rev or repoData.ref; } else - let drv = builtins.fetchGit { inherit (repoData) url ref; }; - in __trace "WARNING: No sha256 found for source-repository-package ${repoData.url} ${repoData.ref} download may fail in restricted mode (hydra)" + let drv = builtins.fetchGit { inherit (repoData) url ; rev = repoData.rev or repoData.ref; ref = repoData.ref or null; }; + in __trace "WARNING: No sha256 found for source-repository-package ${repoData.url} ref=${repoData.ref or "(unspecified)"} rev=${repoData.rev or "(unspecified)"} download may fail in restricted mode (hydra)" (__trace "Consider adding `--sha256: ${hashPath drv}` to the ${cabalProjectFileName} file or passing in a sha256map argument" drv); in {