diff --git a/nixos/modules/services/misc/sourcehut/default.nix b/nixos/modules/services/misc/sourcehut/default.nix index 310b45f0f4d..45b8943ed8e 100644 --- a/nixos/modules/services/misc/sourcehut/default.nix +++ b/nixos/modules/services/misc/sourcehut/default.nix @@ -1134,6 +1134,11 @@ in timerConfig.OnCalendar = ["daily"]; timerConfig.AccuracySec = "1h"; }; + extraServices.hgsrht-api = { + serviceConfig.Restart = "always"; + serviceConfig.RestartSec = "2s"; + serviceConfig.ExecStart = "${pkgs.sourcehut.hgsrht}/bin/hgsrht-api -b ${cfg.listenAddress}:${toString (cfg.hg.port + 100)}"; + }; extraConfig = mkMerge [ { users.users.${cfg.hg.user}.shell = pkgs.bash; diff --git a/pkgs/applications/version-management/sourcehut/hg.nix b/pkgs/applications/version-management/sourcehut/hg.nix index f3e778b2f31..2aa4cc2c505 100644 --- a/pkgs/applications/version-management/sourcehut/hg.nix +++ b/pkgs/applications/version-management/sourcehut/hg.nix @@ -1,21 +1,41 @@ { lib , fetchhg +, buildGoModule , buildPythonPackage , srht , hglib , scmsrht , unidiff , python +, unzip }: buildPythonPackage rec { pname = "hgsrht"; - version = "0.29.4"; + version = "0.31.2"; src = fetchhg { url = "https://hg.sr.ht/~sircmpwn/hg.sr.ht"; rev = version; - sha256 = "Jn9M/R5tJK/GeJDWGo3LWCK2nwsfI9zh+/yo2M+X6Sk="; + sha256 = "F0dBykSSrlis+mumULLxvKNxD75DWR9+IDTYbmhkMDI="; + }; + postPatch = '' + substituteInPlace Makefile \ + --replace "all: api hgsrht-keys" "" + ''; + + hgsrht-api = buildGoModule ({ + inherit src version; + pname = "hgsrht-api"; + modRoot = "api"; + vendorSha256 = "sha256-W7A22qSIgJgcfS7xYNrmbYKaZBXbDtPilM9I6DxmTeU="; + } // import ./fix-gqlgen-trimpath.nix {inherit unzip;}); + + hgsrht-keys = buildGoModule { + inherit src version; + pname = "hgsrht-keys"; + modRoot = "hgsrht-keys"; + vendorSha256 = "sha256-7ti8xCjSrxsslF7/1X/GY4FDl+69hPL4UwCDfjxmJLU="; }; nativeBuildInputs = srht.nativeBuildInputs; @@ -32,6 +52,11 @@ buildPythonPackage rec { export SRHT_PATH=${srht}/${python.sitePackages}/srht ''; + postInstall = '' + ln -s ${hgsrht-api}/bin/api $out/bin/hgsrht-api + ln -s ${hgsrht-keys}/bin/hgsrht-keys $out/bin/hgsrht-keys + ''; + pythonImportsCheck = [ "hgsrht" ]; meta = with lib; {