]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Use flake for openarc modules
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 1 Jan 2021 11:21:09 +0000 (12:21 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 1 Jan 2021 11:34:19 +0000 (12:34 +0100)
flakes/openarc/flake.nix
flakes/openarc/private.nix [new file with mode: 0644]
modules/private/mail/milters.nix

index bdb03581bd680f65a64c99eaf23b592a8c4ea444..9bc104dd7b28a39fa9b46625d5d362f72097b05c 100644 (file)
@@ -75,6 +75,7 @@
         };
     }) // {
       hydraJobs.build = nixpkgs.lib.genAttrs flake-utils.lib.defaultSystems (system: self.defaultPackage."${system}");
+      nixosModules = (if builtins.pathExists ./private.nix then import ./private.nix nixpkgs else {});
       nixosModule = { config, lib, pkgs, ... }:
         let
           cfg = config.services.openarc;
diff --git a/flakes/openarc/private.nix b/flakes/openarc/private.nix
new file mode 100644 (file)
index 0000000..5244ca9
--- /dev/null
@@ -0,0 +1,35 @@
+pkgs:
+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
+        '';
+    };
+    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"
+      ];
+    };
+  };
+in
+  pkgs.lib.genAttrs ["eldiron" "backup-2"] cfg
index 02c35c8a97e9f1e9f753c57113f00a46e04a54b6..96c280066f44b966c55beee99fc7c12d2f961047 100644 (file)
@@ -1,5 +1,8 @@
-{ lib, pkgs, config, ... }:
+{ lib, pkgs, config, name, ... }:
 {
+  imports =
+    builtins.attrValues (import ../../../lib/flake-compat.nix ../../../flakes/openarc).nixosModules;
+
   options.myServices.mail.milters.sockets = lib.mkOption {
     type = lib.types.attrsOf lib.types.path;
     default = {
       ];
     };
 
-    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}
-      '';
-    services.filesWatcher.openarc = {
-      restart = true;
-      paths = [
-        config.secrets.fullPaths."opendkim/eldiron.private"
-      ];
-    };
-
     systemd.services.milter_verify_from = {
       description  = "Verify from milter";
       after = [ "network.target" ];