forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / build-support / fetchhg / default.nix
blob6af886bf09344af7de3075e86ef39ba2326c523a
1 { lib, stdenvNoCC, mercurial }:
2 { name ? null
3 , url
4 , rev ? null
5 , sha256 ? null
6 , hash ? null
7 , fetchSubrepos ? false
8 , preferLocalBuild ? true }:
10 if hash != null && sha256 != null then
11   throw "Only one of sha256 or hash can be set"
12 else
13 # TODO: statically check if mercurial as the https support if the url starts woth https.
14 stdenvNoCC.mkDerivation {
15   name = "hg-archive" + (lib.optionalString (name != null) "-${name}");
16   builder = ./builder.sh;
17   nativeBuildInputs = [mercurial];
19   impureEnvVars = lib.fetchers.proxyImpureEnvVars;
21   subrepoClause = lib.optionalString fetchSubrepos "S";
23   outputHashAlgo = if hash != null then null else "sha256";
24   outputHashMode = "recursive";
25   outputHash = if hash != null then
26     hash
27   else if sha256 != null then
28     sha256
29   else
30     lib.fakeSha256;
32   inherit url rev;
33   inherit preferLocalBuild;