1{ lib
2, fetchFromSourcehut
3, buildGoModule
4, buildPythonPackage
5, python
6, srht
7, scmsrht
8, pygit2
9, minio
10, unzip
11}:
12let
13 version = "0.84.2";
14
15 src = fetchFromSourcehut {
16 owner = "~sircmpwn";
17 repo = "git.sr.ht";
18 rev = version;
19 sha256 = "sha256-sAkTsQlWtNDQ5vAhA2EeOvuJcj9A6AG8pgDyIKtr65s=";
20 };
21
22 gitApi = buildGoModule ({
23 inherit src version;
24 pname = "gitsrht-api";
25 modRoot = "api";
26 vendorHash = "sha256-LAYp0zgosZnFEbtxzjuTH9++0lbxhACr705HqXJz3D0=";
27 } // import ./fix-gqlgen-trimpath.nix { inherit unzip; });
28
29 gitDispatch = buildGoModule {
30 inherit src version;
31 pname = "gitsrht-dispatch";
32 modRoot = "gitsrht-dispatch";
33 vendorHash = "sha256-EDvSZ3/g0xDSohrsAIpNhk+F0yy8tbnTW/3tURTonMc=";
34
35 postPatch = ''
36 substituteInPlace gitsrht-dispatch/main.go \
37 --replace /var/log/gitsrht-dispatch /var/log/sourcehut/gitsrht-dispatch
38 '';
39 };
40
41 gitKeys = buildGoModule {
42 inherit src version;
43 pname = "gitsrht-keys";
44 modRoot = "gitsrht-keys";
45 vendorHash = "sha256-9pojS69HCKVHUceyOpGtv9ewcxFD4WsOVsEzkmWJkF4=";
46
47 postPatch = ''
48 substituteInPlace gitsrht-keys/main.go \
49 --replace /var/log/gitsrht-keys /var/log/sourcehut/gitsrht-keys
50 '';
51 };
52
53 gitShell = buildGoModule {
54 inherit src version;
55 pname = "gitsrht-shell";
56 modRoot = "gitsrht-shell";
57 vendorHash = "sha256-WqfvSPuVsOHA//86u33atMfeA11+DJhjLmWy8Ivq0NI=";
58
59 postPatch = ''
60 substituteInPlace gitsrht-shell/main.go \
61 --replace /var/log/gitsrht-shell /var/log/sourcehut/gitsrht-shell
62 '';
63 };
64
65 gitUpdateHook = buildGoModule {
66 inherit src version;
67 pname = "gitsrht-update-hook";
68 modRoot = "gitsrht-update-hook";
69 vendorHash = "sha256-Bc3yPabS2S+qiroHFKrtkII/CfzBDYQ6xWxKHAME+Tc=";
70
71 postPatch = ''
72 substituteInPlace gitsrht-update-hook/main.go \
73 --replace /var/log/gitsrht-update-hook /var/log/sourcehut/gitsrht-update-hook
74 '';
75 };
76
77in
78buildPythonPackage rec {
79 inherit src version;
80 pname = "gitsrht";
81
82 postPatch = ''
83 substituteInPlace Makefile \
84 --replace "all: api gitsrht-dispatch gitsrht-keys gitsrht-shell gitsrht-update-hook" ""
85 '';
86
87 propagatedBuildInputs = [
88 srht
89 scmsrht
90 pygit2
91 minio
92 ];
93
94 preBuild = ''
95 export PKGVER=${version}
96 export SRHT_PATH=${srht}/${python.sitePackages}/srht
97 '';
98
99 postInstall = ''
100 mkdir -p $out/bin
101 ln -s ${gitApi}/bin/api $out/bin/gitsrht-api
102 ln -s ${gitDispatch}/bin/gitsrht-dispatch $out/bin/gitsrht-dispatch
103 ln -s ${gitKeys}/bin/gitsrht-keys $out/bin/gitsrht-keys
104 ln -s ${gitShell}/bin/gitsrht-shell $out/bin/gitsrht-shell
105 ln -s ${gitUpdateHook}/bin/gitsrht-update-hook $out/bin/gitsrht-update-hook
106 '';
107
108 pythonImportsCheck = [ "gitsrht" ];
109
110 meta = with lib; {
111 homepage = "https://git.sr.ht/~sircmpwn/git.sr.ht";
112 description = "Git repository hosting service for the sr.ht network";
113 license = licenses.agpl3Only;
114 maintainers = with maintainers; [ eadwu ];
115 };
116}