summary refs log tree commit diff stats
path: root/system/settings/services
diff options
context:
space:
mode:
authorAlan Pearce2024-06-25 13:06:09 +0200
committerAlan Pearce2024-06-25 13:06:09 +0200
commit6251530a807833ebf1d16c8a73884942c7490639 (patch)
tree33d30c4cf85591587931084f2e0e8c45957a66d7 /system/settings/services
parentb220cd0f309b9814aeac30334e7fb1b9aac0727d (diff)
downloadnixfiles-6251530a807833ebf1d16c8a73884942c7490639.tar.lz
nixfiles-6251530a807833ebf1d16c8a73884942c7490639.tar.zst
nixfiles-6251530a807833ebf1d16c8a73884942c7490639.zip
git-server: fix mirroring configuration
Diffstat (limited to 'system/settings/services')
-rw-r--r--system/settings/services/git-server.nix34
1 files 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
+    ];
   };
 }