forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / applications / version-management / sourcehut / hg.nix
blob3e7e1f55c65a9b81f0021cb3624e1f3a4a415360
1 { lib
2 , fetchFromSourcehut
3 , buildGoModule
4 , buildPythonPackage
5 , srht
6 , python-hglib
7 , scmsrht
8 , unidiff
9 , python
10 , unzip
11 , pip
12 , pythonOlder
13 , setuptools
16 let
17   version = "0.33.0";
18   gqlgen = import ./fix-gqlgen-trimpath.nix { inherit unzip; gqlgenVersion = "0.17.45"; };
20   pyproject = true;
22   disabled = pythonOlder "3.7";
24   src = fetchFromSourcehut {
25     owner = "~sircmpwn";
26     repo = "hg.sr.ht";
27     rev = version;
28     hash = "sha256-+BYeE+8dXY/MLLYyBBLD+eKqmrPiKyyCGIZLkCPzNYM=";
29     vc = "hg";
30   };
32   hgsrht-api = buildGoModule ({
33     inherit src version;
34     pname = "hgsrht-api";
35     modRoot = "api";
36     vendorHash = "sha256-K+KMhcvkG/qeQTnlHS4xhLCcvBQNNp2DcScJPm8Dbic=";
37   } // gqlgen);
39   hgsrht-keys = buildGoModule {
40     inherit src version;
41     pname = "hgsrht-keys";
42     modRoot = "hgsrht-keys";
43     vendorHash = "sha256-7ti8xCjSrxsslF7/1X/GY4FDl+69hPL4UwCDfjxmJLU=";
45     postPatch = ''
46       substituteInPlace hgsrht-keys/main.go \
47         --replace /var/log/hgsrht-keys /var/log/sourcehut/hgsrht-keys
48     '';
49   };
51 buildPythonPackage rec {
52   inherit src version;
53   pname = "hgsrht";
55   postPatch = ''
56     substituteInPlace Makefile \
57       --replace "all: api hgsrht-keys" ""
59     substituteInPlace hgsrht-shell \
60       --replace /var/log/hgsrht-shell /var/log/sourcehut/hgsrht-shell
61   '';
63   nativeBuildInputs = [
64     pip
65     setuptools
66   ];
68   propagatedBuildInputs = [
69     python-hglib
70     scmsrht
71     srht
72     unidiff
73   ];
75   preBuild = ''
76     export PKGVER=${version}
77     export SRHT_PATH=${srht}/${python.sitePackages}/srht
78   '';
80   postInstall = ''
81     ln -s ${hgsrht-api}/bin/api $out/bin/hgsrht-api
82     ln -s ${hgsrht-keys}/bin/hgsrht-keys $out/bin/hgsrht-keys
83   '';
85   pythonImportsCheck = [ "hgsrht" ];
87   meta = with lib; {
88     homepage = "https://git.sr.ht/~sircmpwn/hg.sr.ht";
89     description = "Mercurial repository hosting service for the sr.ht network";
90     license = licenses.agpl3Only;
91     maintainers = with maintainers; [ eadwu christoph-heiss ];
92   };