1{
2 lib,
3 stdenvNoCC,
4 mercurial,
5}:
6
7lib.extendMkDerivation {
8 constructDrv = stdenvNoCC.mkDerivation;
9
10 extendDrvArgs =
11 finalAttrs:
12 {
13 name ? null,
14 url,
15 rev ? null,
16 sha256 ? null,
17 hash ? null,
18 fetchSubrepos ? false,
19 preferLocalBuild ? true,
20 }:
21 # TODO: statically check if mercurial as the https support if the url starts with https.
22 {
23 name = "hg-archive" + (lib.optionalString (name != null) "-${name}");
24 builder = ./builder.sh;
25 nativeBuildInputs = [ mercurial ];
26
27 impureEnvVars = lib.fetchers.proxyImpureEnvVars;
28
29 subrepoClause = lib.optionalString fetchSubrepos "S";
30
31 outputHashAlgo = if finalAttrs.hash != null && finalAttrs.hash != "" then null else "sha256";
32 outputHashMode = "recursive";
33 outputHash = lib.throwIf (hash != null && sha256 != null) "Only one of sha256 or hash can be set" (
34 if finalAttrs.hash != null then
35 finalAttrs.hash
36 else if sha256 != null then
37 sha256
38 else
39 ""
40 );
41
42 inherit url rev hash;
43 inherit preferLocalBuild;
44 };
45
46 # No ellipsis
47 inheritFunctionArgs = false;
48}