1 { lib, pkgs, config, ... }:
3 cfg = config.myServices.tools.kanboard.farm;
4 apacheUser = config.services.httpd.Tools.user;
5 apacheGroup = config.services.httpd.Tools.group;
6 toVardir = name: "/var/lib/kanboard_farm/${name}";
7 varDirs = lib.mapAttrsToList (name: v: toVardir name) cfg.instances;
8 toPhpBaseDir = name: [ rootDir (toVardir name) ];
9 phpBaseDir = builtins.concatStringsSep ":" (lib.unique (lib.flatten (lib.mapAttrsToList (name: v: toPhpBaseDir name) cfg.instances)));
10 rootDir = pkgs.kanboard;
13 Alias /${name} "${rootDir}"
15 SetEnv DATA_DIR "${toVardir name}"
16 SetEnv MAIL_FROM "kanboard@tools.immae.eu"
19 toCustomVhost = name: lib.optionalAttrs (cfg.instances."${name}".customHost != null) {
20 "kanboard_farm_${name}" = {
23 hosts = [cfg.instances."${name}".customHost];
29 SetEnv DATA_DIR "${toVardir name}"
30 SetEnv MAIL_FROM "kanboard@tools.immae.eu"
32 <Directory "${rootDir}">
33 DirectoryIndex index.php
35 Options FollowSymlinks
39 SetHandler "proxy:unix:${config.services.phpfpm.pools.kanboard_farm.socket}|fcgi://localhost"
42 <DirectoryMatch "${rootDir}/data">
49 customVhosts = lib.foldl (o: n: o // n) {} (map toCustomVhost (builtins.attrNames cfg.instances));
50 phpPackage = pkgs.php74;
53 options.myServices.tools.kanboard.farm = {
54 instances = lib.mkOption {
55 description = "Instances names for the kanboard Farm";
57 type = lib.types.attrsOf (lib.types.submodule {
59 customHost = lib.mkOption {
60 description = "Custom host to use for the kanboard instance";
62 type = lib.types.nullOr lib.types.str;
67 vhosts = lib.mkOption {
68 description = "Instance vhosts configs";
70 type = lib.types.attrsOf lib.types.str;
71 default = lib.mapAttrs (name: v: toVhost name) cfg.instances;
75 config = lib.mkIf (builtins.length (builtins.attrNames cfg.instances) > 0) {
76 myServices.chatonsProperties.hostings.kanboard = {
77 file.datetime = "2022-08-21T19:40:00";
80 description = "Kanban project management software";
81 website = "https://tools.immae.eu/kanboard";
82 logo = "https://tools.immae.eu/kanboard/assets/img/favicon.png";
85 status.description = "OK";
86 registration.load = "OPEN";
87 install.type = "PACKAGE";
90 myServices.chatonsProperties.services.kanboard = {
91 file.datetime = "2022-08-21T19:40:00";
94 description = "Kanban project management software";
95 website = "https://tools.immae.eu/kanboard";
96 logo = "https://tools.immae.eu/kanboard/assets/img/favicon.png";
98 status.description = "OK";
99 registration."" = ["MEMBER" "CLIENT"];
100 registration.load = "OPEN";
101 install.type = "PACKAGE";
105 website = "https://kanboard.org/";
106 license.url = "https://github.com/kanboard/kanboard/blob/main/LICENSE";
107 license.name = "MIT License";
108 version = pkgs.kanboard.version;
109 source.url = "https://github.com/kanboard/kanboard";
112 system.activationScripts.kanboard_farm_vardirs = {
115 install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d ${builtins.concatStringsSep " " varDirs}
116 install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/kanboard_farm/phpSessions
119 services.phpfpm.pools.kanboard_farm = {
123 instanceNb = builtins.length (builtins.attrNames cfg.instances);
125 "listen.owner" = apacheUser;
126 "listen.group" = apacheGroup;
128 "pm.max_children" = builtins.toString (60 * instanceNb);
129 "pm.start_servers" = builtins.toString (2 * instanceNb);
130 "pm.min_spare_servers" = builtins.toString (2 * instanceNb);
131 "pm.max_spare_servers" = builtins.toString (3 * instanceNb);
132 "pm.process_idle_timeout" = "60";
134 "php_admin_value[output_buffering]" = "0";
135 "php_admin_value[max_execution_time]" = "1800";
136 "php_admin_value[zend_extension]" = "opcache";
137 "php_value[apcu.enable_cli]" = "1";
138 "php_value[apcu.enabled]" = "1";
139 #already enabled by default?
140 #"php_value[opcache.enable]" = "1";
141 "php_value[opcache.enable_cli]" = "1";
142 "php_value[opcache.interned_strings_buffer]" = "8";
143 "php_value[opcache.max_accelerated_files]" = "10000";
144 "php_value[opcache.memory_consumption]" = "128";
145 "php_value[opcache.save_comments]" = "1";
146 "php_value[opcache.revalidate_freq]" = "1";
147 "php_admin_value[memory_limit]" = "512M";
149 "php_admin_value[open_basedir]" = "/run/wrappers/bin/sendmail:${phpBaseDir}:/proc/meminfo:/dev/urandom:/proc/self/fd:/tmp";
150 "php_admin_value[session.save_path]" = "/var/lib/kanboard_farm/phpSessions";
154 services.websites.env.tools.vhostConfs = {
156 certName = "eldiron";
158 hosts = ["kanboard.immae.eu"];
162 <Directory "${rootDir}">
163 DirectoryIndex index.php
165 Options FollowSymlinks
168 <FilesMatch "\.php$">
169 SetHandler "proxy:unix:${config.services.phpfpm.pools.kanboard_farm.socket}|fcgi://localhost"
172 <DirectoryMatch "${rootDir}/data">
176 ] ++ builtins.attrValues cfg.vhosts;