diff options
Diffstat (limited to 'nix/tamal/default.nix')
| -rw-r--r-- | nix/tamal/default.nix | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/nix/tamal/default.nix b/nix/tamal/default.nix index a995c23..ee07ccd 100644 --- a/nix/tamal/default.nix +++ b/nix/tamal/default.nix @@ -84,6 +84,40 @@ let ${hash.al} = hash.vl; } // lib.optionalAttrs (builtins.length kind.ms > 0) { urls = kind.ms; }; + fetch-darcs = {name, kind, hash}: + let + using-mirrors = kind ? ms && (builtins.length kind.ms) > 0; + mirror-support = pkgs.fetchdarcs.__functionArgs ? "mirrors"; + reference = + let + type = builtins.elemAt kind.rf 0; + value = builtins.elemAt kind.rf 1; + in + if type == 0 then + let path = builtins.elemAt value 1; in + assert (lib.hasSuffix ".txt" path); + let + txt-files = lib.sourceFilesBySuffices ./. [ ".txt" ]; + dir = lib.fileset.toSource { + root = ./.; + fileset = lib.fileset.fromSource txt-files; + }; + in + {context = "${dir}/${path}";} + else if type == 1 then + {rev = value;} + else + throw "Invalid Darcs reference"; + in + lib.warnIf (using-mirrors && !mirror-support) + "Upstream pkgs.fetchdarcs doesn’t yet support mirrors for 「${name}」" + pkgs.fetchdarcs ({ + url = kind.rp; + ${hash.al} = hash.vl; + } // reference // lib.optionalAttrs (using-mirrors && mirror-support){ + mirrors = kind.ms; + }); + to-input = name: input: let k = builtins.head input.kd; in if k == 1 then @@ -92,6 +126,12 @@ let kind = builtins.elemAt input.kd 1; hash = input.ha; } +else if k == 3 then + fetch-darcs { + inherit name; + kind = builtins.elemAt input.kd 1; + hash = input.ha; + } else throw "Unsupported input kind “${builtins.toString k}”."; in |
