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 phpPackage = pkgs.php74;
22 options.myServices.tools.kanboard.farm = {
23 instances = lib.mkOption {
24 description = "Instances names for the kanboard Farm";
26 type = lib.types.attrsOf (lib.types.submodule {
30 vhosts = lib.mkOption {
31 description = "Instance vhosts configs";
33 type = lib.types.attrsOf lib.types.str;
34 default = lib.mapAttrs (name: v: toVhost name) cfg.instances;
38 config = lib.mkIf (builtins.length (builtins.attrNames cfg.instances) > 0) {
39 system.activationScripts.kanboard_farm_vardirs = {
42 install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d ${builtins.concatStringsSep " " varDirs}
43 install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/kanboard_farm/phpSessions
46 services.phpfpm.pools.kanboard_farm = {
50 instanceNb = builtins.length (builtins.attrNames cfg.instances);
52 "listen.owner" = apacheUser;
53 "listen.group" = apacheGroup;
55 "pm.max_children" = builtins.toString (60 * instanceNb);
56 "pm.start_servers" = builtins.toString (2 * instanceNb);
57 "pm.min_spare_servers" = builtins.toString (2 * instanceNb);
58 "pm.max_spare_servers" = builtins.toString (3 * instanceNb);
59 "pm.process_idle_timeout" = "60";
61 "php_admin_value[output_buffering]" = "0";
62 "php_admin_value[max_execution_time]" = "1800";
63 "php_admin_value[zend_extension]" = "opcache";
64 "php_value[apcu.enable_cli]" = "1";
65 "php_value[apcu.enabled]" = "1";
66 #already enabled by default?
67 #"php_value[opcache.enable]" = "1";
68 "php_value[opcache.enable_cli]" = "1";
69 "php_value[opcache.interned_strings_buffer]" = "8";
70 "php_value[opcache.max_accelerated_files]" = "10000";
71 "php_value[opcache.memory_consumption]" = "128";
72 "php_value[opcache.save_comments]" = "1";
73 "php_value[opcache.revalidate_freq]" = "1";
74 "php_admin_value[memory_limit]" = "512M";
76 "php_admin_value[open_basedir]" = "/run/wrappers/bin/sendmail:${phpBaseDir}:/proc/meminfo:/dev/urandom:/proc/self/fd:/tmp";
77 "php_admin_value[session.save_path]" = "/var/lib/kanboard_farm/phpSessions";
81 services.websites.env.tools.vhostConfs.kanboard = {
84 hosts = ["kanboard.immae.eu"];
88 <Directory "${rootDir}">
89 DirectoryIndex index.php
91 Options FollowSymlinks
95 SetHandler "proxy:unix:${config.services.phpfpm.pools.kanboard_farm.socket}|fcgi://localhost"
98 <DirectoryMatch "${rootDir}/data">
102 ] ++ builtins.attrValues cfg.vhosts;