all repos — nixfiles @ 6251530a807833ebf1d16c8a73884942c7490639

System and user configuration, managed by nix and home-manager

git-server: fix mirroring configuration

Alan Pearce
commit

6251530a807833ebf1d16c8a73884942c7490639

parent

b220cd0f309b9814aeac30334e7fb1b9aac0727d

1 file changed, 17 insertions(+), 17 deletions(-)

jump to
M system/settings/services/git-server.nixsystem/settings/services/git-server.nix
@@ -4,8 +4,7 @@ , pkgs
, ... }: 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 @@
createMirrorService = name: { hostname, username }: { - services."mirror-to-${name}@" = { + "mirror-to-${name}@" = { path = with pkgs; [ gitMinimal openssh ]; serviceConfig = { Type = "oneshot";
@@ -48,7 +47,11 @@ # only mirror public repositories
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";
@@ -56,6 +59,7 @@ StartLimitBurst = 5;
}; }; }; + mkMirrorWants = repo: map (target: "mirror-to-${target}@${repo}.path"); in
@@ -262,18 +266,14 @@ '')
]; }; - 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 + ]; }; }