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