]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Add kanboard for gebull
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 7 Apr 2022 11:39:30 +0000 (13:39 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sun, 9 Apr 2023 15:16:20 +0000 (17:16 +0200)
modules/private/websites/default.nix
modules/private/websites/tools/kanboard/farm.nix

index 0918908da4a4afdcd9cf21cbd13b8ce0bb563581..aba216cc8017c95f9fde5b6d9f0c6387c43d6183 100644 (file)
@@ -212,7 +212,8 @@ in
       };
     };
 
-    myServices.tools.kanboard.farm.instances.tonnelle = null;
+    myServices.tools.kanboard.farm.instances.tonnelle = {};
+    myServices.tools.kanboard.farm.instances.gebull = {};
     myServices.websites = {
       bakeer.cloud.enable = true;
       capitaines.landing_pages.enable = true;
index 7967c51fa1a191a7137feec2c07d783f9fee6ef4..5e37292fddb6a913facecd2f3accd07add984ceb 100644 (file)
@@ -16,6 +16,37 @@ let
       SetEnv MAIL_FROM "kanboard@tools.immae.eu"
     </Location>
     '';
+  toCustomVhost = name: lib.optionalAttrs (cfg.instances."${name}".customHost != null) {
+    "kanboard_farm_${name}" = {
+      certName = "eldiron";
+      addToCerts = true;
+      hosts = [cfg.instances."${name}".customHost];
+      root = null;
+      extraConfig = [
+        ''
+        Alias / "${rootDir}"
+        <Location />
+          SetEnv DATA_DIR "${toVardir name}"
+          SetEnv MAIL_FROM "kanboard@tools.immae.eu"
+        </Location>
+        <Directory "${rootDir}">
+          DirectoryIndex index.php
+          AllowOverride All
+          Options FollowSymlinks
+          Require all granted
+
+          <FilesMatch "\.php$">
+            SetHandler "proxy:unix:${config.services.phpfpm.pools.kanboard_farm.socket}|fcgi://localhost"
+          </FilesMatch>
+        </Directory>
+        <DirectoryMatch "${rootDir}/data">
+          Require all denied
+        </DirectoryMatch>
+          ''
+      ];
+    };
+  };
+  customVhosts = lib.foldl (o: n: o // n) {} (map toCustomVhost (builtins.attrNames cfg.instances));
   phpPackage = pkgs.php74;
 in
 {
@@ -24,7 +55,13 @@ in
       description = "Instances names for the kanboard Farm";
       default = {};
       type = lib.types.attrsOf (lib.types.submodule {
-        options = {};
+        options = {
+          customHost = lib.mkOption {
+            description = "Custom host to use for the kanboard instance";
+            default = null;
+            type = lib.types.nullOr lib.types.str;
+          };
+        };
       });
     };
     vhosts = lib.mkOption {
@@ -78,28 +115,30 @@ in
       };
       inherit phpPackage;
     };
-    services.websites.env.tools.vhostConfs.kanboard = {
-      certName = "eldiron";
-      addToCerts = true;
-      hosts = ["kanboard.immae.eu"];
-      root = null;
-      extraConfig = [
-        ''
-        <Directory "${rootDir}">
-          DirectoryIndex index.php
-          AllowOverride All
-          Options FollowSymlinks
-          Require all granted
-
-          <FilesMatch "\.php$">
-            SetHandler "proxy:unix:${config.services.phpfpm.pools.kanboard_farm.socket}|fcgi://localhost"
-          </FilesMatch>
-        </Directory>
-        <DirectoryMatch "${rootDir}/data">
-          Require all denied
-        </DirectoryMatch>
+    services.websites.env.tools.vhostConfs = {
+      kanboard = {
+        certName = "eldiron";
+        addToCerts = true;
+        hosts = ["kanboard.immae.eu"];
+        root = null;
+        extraConfig = [
           ''
-      ] ++ builtins.attrValues cfg.vhosts;
-    };
+          <Directory "${rootDir}">
+            DirectoryIndex index.php
+            AllowOverride All
+            Options FollowSymlinks
+            Require all granted
+
+            <FilesMatch "\.php$">
+              SetHandler "proxy:unix:${config.services.phpfpm.pools.kanboard_farm.socket}|fcgi://localhost"
+            </FilesMatch>
+          </Directory>
+          <DirectoryMatch "${rootDir}/data">
+            Require all denied
+          </DirectoryMatch>
+            ''
+        ] ++ builtins.attrValues cfg.vhosts;
+      };
+    } // customVhosts;
   };
 }