Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
112 lines
2.6 KiB
Nix
112 lines
2.6 KiB
Nix
{
|
|
lib,
|
|
repoRevToNameMaybe,
|
|
fetchgit,
|
|
fetchzip,
|
|
}:
|
|
|
|
lib.makeOverridable (
|
|
{
|
|
owner,
|
|
repo,
|
|
tag ? null,
|
|
rev ? null,
|
|
name ? repoRevToNameMaybe repo (lib.revOrTag rev tag) "bitbucket",
|
|
fetchSubmodules ? false,
|
|
leaveDotGit ? false,
|
|
deepClone ? false,
|
|
forceFetchGit ? false,
|
|
fetchLFS ? false,
|
|
rootDir ? "",
|
|
sparseCheckout ? lib.optional (rootDir != "") rootDir,
|
|
meta ? { },
|
|
... # For hash agility
|
|
}@args:
|
|
|
|
assert (
|
|
lib.assertMsg (lib.xor (tag == null) (
|
|
rev == null
|
|
)) "fetchFromBitbucket requires one of either `rev` or `tag` to be provided (not both)."
|
|
);
|
|
|
|
let
|
|
position = (
|
|
if args.meta.description or null != null then
|
|
builtins.unsafeGetAttrPos "description" args.meta
|
|
else if tag != null then
|
|
builtins.unsafeGetAttrPos "tag" args
|
|
else
|
|
builtins.unsafeGetAttrPos "rev" args
|
|
);
|
|
baseUrl = "https://bitbucket.org/${owner}/${repo}";
|
|
newMeta =
|
|
meta
|
|
// {
|
|
homepage = meta.homepage or baseUrl;
|
|
}
|
|
// lib.optionalAttrs (position != null) {
|
|
# to indicate where derivation originates, similar to make-derivation.nix's mkDerivation
|
|
position = "${position.file}:${toString position.line}";
|
|
};
|
|
gitRepoUrl = "${baseUrl}.git";
|
|
|
|
# the tag is escaped to support mercurial-based tags as bitbucket supports them
|
|
revWithTag = if tag != null then "refs/tags/${lib.strings.escapeURL tag}" else rev;
|
|
|
|
passthruAttrs = removeAttrs args [
|
|
"owner"
|
|
"repo"
|
|
"rev"
|
|
"tag"
|
|
"fetchSubmodules"
|
|
"forceFetchGit"
|
|
];
|
|
|
|
useFetchGit =
|
|
fetchSubmodules
|
|
|| (leaveDotGit == true)
|
|
|| deepClone
|
|
|| forceFetchGit
|
|
|| fetchLFS
|
|
|| (rootDir != "")
|
|
|| (sparseCheckout != [ ]);
|
|
|
|
fetcher = if useFetchGit then fetchgit else fetchzip;
|
|
|
|
fetcherArgs =
|
|
(
|
|
if useFetchGit then
|
|
{
|
|
inherit
|
|
rev
|
|
tag
|
|
deepClone
|
|
fetchSubmodules
|
|
sparseCheckout
|
|
fetchLFS
|
|
;
|
|
url = gitRepoUrl;
|
|
}
|
|
// lib.optionalAttrs (leaveDotGit != null) { inherit leaveDotGit; }
|
|
else
|
|
{
|
|
url = "https://bitbucket.org/${owner}/${repo}/get/${revWithTag}.tar.gz";
|
|
extension = "tar.gz";
|
|
passthru = {
|
|
inherit gitRepoUrl;
|
|
};
|
|
}
|
|
)
|
|
// passthruAttrs
|
|
// {
|
|
inherit name;
|
|
};
|
|
in
|
|
fetcher fetcherArgs
|
|
// {
|
|
meta = newMeta;
|
|
inherit owner repo tag;
|
|
rev = revWithTag;
|
|
}
|
|
)
|