summary refs log tree commit diff
path: root/pkgs/build-support/fetchsourcehut/default.nix
blob: ed2f074200cd0ddb8e15dad501aa946ed077bc19 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{ fetchzip, lib }:

{ owner
, repo, rev
, domain ? "sr.ht"
, vc ? "git"
, name ? "source"
, ... # For hash agility
} @ args:

with lib;

assert (lib.assertOneOf "vc" vc [ "hg" "git" ]);

let
  baseUrl = "https://${vc}.${domain}/${owner}/${repo}";

in fetchzip (recursiveUpdate {
  inherit name;
  url = "${baseUrl}/archive/${rev}.tar.gz";
  meta.homepage = "${baseUrl}/";
  extraPostFetch = optionalString (vc == "hg") ''
    rm -f "$out/.hg_archival.txt"
  ''; # impure file; see #12002
} (removeAttrs args [ "owner" "repo" "rev" "domain" "vc" ])) // { inherit rev; }