Something went wrong. Try again.
What happens if I push all of nixpkgs
Something went wrong. Try again.
1.6 kB · 88 lines
Nix
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889{ lib, repoRevToNameMaybe, fetchgit, fetchhg, fetchzip,}:
let inherit (lib) assertOneOf makeOverridable optionalString ;in
makeOverridable ( { owner, repo, rev, name ? repoRevToNameMaybe repo rev "sourcehut", domain ? "sr.ht", vc ? "git", fetchSubmodules ? false, ... # For hash agility }@args:
assert ( assertOneOf "vc" vc [ "hg" "git" ] );
let urlFor = resource: "https://${resource}.${domain}/${owner}/${repo}"; baseUrl = urlFor vc; baseArgs = { inherit name; } // removeAttrs args [ "owner" "repo" "rev" "domain" "vc" "name" "fetchSubmodules" ]; vcArgs = baseArgs // { inherit rev; url = baseUrl; }; fetcher = if fetchSubmodules then vc else "zip"; cases = { git = { fetch = fetchgit; arguments = vcArgs // { fetchSubmodules = true; }; }; hg = { fetch = fetchhg; arguments = vcArgs // { fetchSubrepos = true; }; }; zip = { fetch = fetchzip; arguments = baseArgs // { url = "${baseUrl}/archive/${rev}.tar.gz"; postFetch = optionalString (vc == "hg") '' rm -f "$out/.hg_archival.txt" ''; # impure file; see #12002 passthru = { gitRepoUrl = urlFor "git"; }; }; }; }; in cases.${fetcher}.fetch cases.${fetcher}.arguments // { inherit rev; meta.homepage = "${baseUrl}"; })