Skip to content

Determine if the tag is a ref or a rev #1665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/cabal-project-parser.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
6 changes: 3 additions & 3 deletions lib/call-cabal-project-to-nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down