]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - flakes/private/openarc/flake.nix
Add filesWatcher flake
[perso/Immae/Config/Nix.git] / flakes / private / openarc / flake.nix
index fd8ec5687ca95b14867289555a05b153c016f594..9cc9aedd1d734d43728c20c389dc2837602f8e84 100644 (file)
@@ -3,40 +3,51 @@
     path = "../../openarc";
     type = "path";
   };
+  inputs.files-watcher = {
+    path = "../../files-watcher";
+    type = "path";
+  };
+  inputs.my-lib = {
+    path = "../../lib";
+    type = "path";
+  };
   inputs.nix-lib.url = "github:NixOS/nixpkgs";
 
   description = "Private configuration for openarc";
-  outputs = { self, nix-lib, openarc }:
+  outputs = { self, nix-lib, my-lib, files-watcher, openarc }:
     let
-      cfg = name': { config, lib, pkgs, name, ... }: lib.mkIf (name == name') {
-        services.openarc = {
-          enable = true;
-          user = "opendkim";
-          socket = "local:${config.myServices.mail.milters.sockets.openarc}";
-          group = config.services.postfix.group;
-          configFile = pkgs.writeText "openarc.conf" ''
-            AuthservID              mail.immae.eu
-            Domain                  mail.immae.eu
-            KeyFile                 ${config.secrets.fullPaths."opendkim/eldiron.private"}
-            Mode                    sv
-            Selector                eldiron
-            SoftwareHeader          yes
-            Syslog                  Yes
+      cfg = name': { config, lib, pkgs, name, ... }: {
+        imports = [ (my-lib.lib.withNarKey files-watcher "nixosModule") ];
+        config = lib.mkIf (name == name') {
+          services.openarc = {
+            enable = true;
+            user = "opendkim";
+            socket = "local:${config.myServices.mail.milters.sockets.openarc}";
+            group = config.services.postfix.group;
+            configFile = pkgs.writeText "openarc.conf" ''
+              AuthservID              mail.immae.eu
+              Domain                  mail.immae.eu
+              KeyFile                 ${config.secrets.fullPaths."opendkim/eldiron.private"}
+              Mode                    sv
+              Selector                eldiron
+              SoftwareHeader          yes
+              Syslog                  Yes
+              '';
+          };
+          systemd.services.openarc.serviceConfig.Slice = "mail.slice";
+          systemd.services.openarc.postStart = lib.optionalString
+                (lib.strings.hasPrefix "local:" config.services.openarc.socket) ''
+            while [ ! -S ${lib.strings.removePrefix "local:" config.services.openarc.socket} ]; do
+              sleep 0.5
+            done
+            chmod g+w ${lib.strings.removePrefix "local:" config.services.openarc.socket}
             '';
-        };
-        systemd.services.openarc.serviceConfig.Slice = "mail.slice";
-        systemd.services.openarc.postStart = lib.optionalString
-              (lib.strings.hasPrefix "local:" config.services.openarc.socket) ''
-          while [ ! -S ${lib.strings.removePrefix "local:" config.services.openarc.socket} ]; do
-            sleep 0.5
-          done
-          chmod g+w ${lib.strings.removePrefix "local:" config.services.openarc.socket}
-          '';
-        services.filesWatcher.openarc = {
-          restart = true;
-          paths = [
-            config.secrets.fullPaths."opendkim/eldiron.private"
-          ];
+          services.filesWatcher.openarc = {
+            restart = true;
+            paths = [
+              config.secrets.fullPaths."opendkim/eldiron.private"
+            ];
+          };
         };
       };
     in