From 43f856ab2c411ddd2aca58b84a157f807672c8ab Mon Sep 17 00:00:00 2001 From: Julien Moutinho Date: Fri, 6 May 2022 00:01:39 +0200 Subject: [PATCH] sourcehut.buildsrht: 0.75.2 -> 0.79.1 --- .../services/misc/sourcehut/default.nix | 13 +++++++--- .../version-management/sourcehut/builds.nix | 25 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/nixos/modules/services/misc/sourcehut/default.nix b/nixos/modules/services/misc/sourcehut/default.nix index 5a6d011a729a..746ddbf8f440 100644 --- a/nixos/modules/services/misc/sourcehut/default.nix +++ b/nixos/modules/services/misc/sourcehut/default.nix @@ -905,6 +905,11 @@ in inherit configIniOfService; srvsrht = "buildsrht"; port = 5002; + extraServices.buildsrht-api = { + serviceConfig.Restart = "always"; + serviceConfig.RestartSec = "2s"; + serviceConfig.ExecStart = "${pkgs.sourcehut.buildsrht}/bin/buildsrht-api -b ${cfg.listenAddress}:${toString (cfg.builds.port + 100)}"; + }; # TODO: a celery worker on the master and worker are apparently needed extraServices.buildsrht-worker = let qemuPackage = pkgs.qemu_kvm; @@ -928,13 +933,13 @@ in fi ''; serviceConfig = { - ExecStart = "${pkgs.sourcehut.buildsrht}/bin/builds.sr.ht-worker"; + ExecStart = "${pkgs.sourcehut.buildsrht}/bin/buildsrht-worker"; BindPaths = [ cfg.settings."builds.sr.ht::worker".buildlogs ]; LogsDirectory = [ "sourcehut/${serviceName}" ]; RuntimeDirectory = [ "sourcehut/${serviceName}/subdir" ]; StateDirectory = [ "sourcehut/${serviceName}" ]; TimeoutStartSec = "1800s"; - # builds.sr.ht-worker looks up ../config.ini + # buildsrht-worker looks up ../config.ini WorkingDirectory = "-"+"/run/sourcehut/${serviceName}/subdir"; }; }; @@ -952,12 +957,12 @@ in ) cfg.builds.images ); image_dir_pre = pkgs.symlinkJoin { - name = "builds.sr.ht-worker-images-pre"; + name = "buildsrht-worker-images-pre"; paths = image_dirs; # FIXME: not working, apparently because ubuntu/latest is a broken link # ++ [ "${pkgs.sourcehut.buildsrht}/lib/images" ]; }; - image_dir = pkgs.runCommand "builds.sr.ht-worker-images" { } '' + image_dir = pkgs.runCommand "buildsrht-worker-images" { } '' mkdir -p $out/images cp -Lr ${image_dir_pre}/* $out/images ''; diff --git a/pkgs/applications/version-management/sourcehut/builds.nix b/pkgs/applications/version-management/sourcehut/builds.nix index 350afd07fe19..e2cc01eb9c70 100644 --- a/pkgs/applications/version-management/sourcehut/builds.nix +++ b/pkgs/applications/version-management/sourcehut/builds.nix @@ -1,7 +1,7 @@ { lib , fetchFromSourcehut -, buildPythonPackage , buildGoModule +, buildPythonPackage , srht , redis , celery @@ -9,21 +9,29 @@ , markdown , ansi2html , python +, unzip }: let - version = "0.75.2"; + version = "0.79.1"; src = fetchFromSourcehut { owner = "~sircmpwn"; repo = "builds.sr.ht"; rev = version; - sha256 = "sha256-SwyxMzmp9baRQ0vceuEn/OpfIv7z7jwq/l67hdOHXjM="; + sha256 = "sha256-8fZ6KdD+9+n0uO3jm0AUyG08oCUNFq1K55ZOwLbkpHk="; }; - buildWorker = src: buildGoModule { + buildsrht-api = buildGoModule ({ inherit src version; - pname = "builds-sr-ht-worker"; + pname = "buildsrht-api"; + modRoot = "api"; + vendorSha256 = "sha256-roTwqtg4Y846PNtLdRN/LV3Jd0LVElqjFy3DJcrwoaI="; + } // import ./fix-gqlgen-trimpath.nix {inherit unzip;}); + buildsrht-worker = buildGoModule { + inherit src version; + sourceRoot = "source/worker"; + pname = "buildsrht-worker"; vendorSha256 = "sha256-Pf1M9a43eK4jr6QMi6kRHA8DodXQU0pqq9ua5VC3ER0="; }; in @@ -35,6 +43,10 @@ buildPythonPackage rec { # Revert change breaking Unix socket support for Redis patches/redis-socket/build/0001-Revert-Add-build-submission-and-queue-monitoring.patch ]; + postPatch = '' + substituteInPlace Makefile \ + --replace "all: api worker" "" + ''; nativeBuildInputs = srht.nativeBuildInputs; @@ -58,7 +70,8 @@ buildPythonPackage rec { cp -r images $out/lib cp contrib/submit_image_build $out/bin/builds.sr.ht - cp ${buildWorker "${src}/worker"}/bin/worker $out/bin/builds.sr.ht-worker + ln -s ${buildsrht-api}/bin/api $out/bin/buildsrht-api + ln -s ${buildsrht-worker}/bin/worker $out/bin/buildsrht-worker ''; pythonImportsCheck = [ "buildsrht" ];