From 6251530a807833ebf1d16c8a73884942c7490639 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Tue, 25 Jun 2024 13:06:09 +0200 Subject: git-server: fix mirroring configuration --- system/settings/services/git-server.nix | 34 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/system/settings/services/git-server.nix b/system/settings/services/git-server.nix index 946bf4ba..54e8560c 100644 --- a/system/settings/services/git-server.nix +++ b/system/settings/services/git-server.nix @@ -4,8 +4,7 @@ , ... }: let - inherit (builtins) mapAttrs attrValues; - inherit (lib) pipe flatten mergeAttrsList mapAttrsToList; + inherit (lib) pipe flatten concatMapAttrs mergeAttrsList mapAttrsToList; inherit (import ../../../lib/caddy.nix { inherit lib; }) security-headers; repos = "${config.services.gitolite.dataDir}/repositories"; @@ -35,7 +34,7 @@ let createMirrorService = name: { hostname, username }: { - services."mirror-to-${name}@" = { + "mirror-to-${name}@" = { path = with pkgs; [ gitMinimal openssh ]; serviceConfig = { Type = "oneshot"; @@ -48,7 +47,11 @@ let ConditionPathExists = "${repos}/%i.git/git-daemon-export-ok"; }; }; - paths."mirror-to-${name}@" = { + }; + + createMirrorPath = name: { hostname, username }: + { + "mirror-to-${name}@" = { pathConfig = { PathChanged = "${repos}/%i.git/refs/heads"; StartLimitIntervalSec = "1h"; @@ -57,6 +60,7 @@ let }; }; + mkMirrorWants = repo: map (target: "mirror-to-${target}@${repo}.path"); in { @@ -262,18 +266,14 @@ in ]; }; - systemd = (pipe - mirrors [ - (mapAttrsToList createMirrorService) - mergeAttrsList - ]) // { - targets.git-mirroring = { - wantedBy = [ "multi-user.target" ]; - wants = pipe - repoMirrors [ - (mapAttrsToList mkMirrorWants) - flatten - ]; - }; + systemd.services = concatMapAttrs createMirrorService mirrors; + systemd.paths = concatMapAttrs createMirrorPath mirrors; + systemd.targets.git-mirroring = { + wantedBy = [ "multi-user.target" ]; + wants = pipe + repoMirrors [ + (mapAttrsToList mkMirrorWants) + flatten + ]; }; } -- cgit 1.4.1