blob: 8318282ecdd264a5a6389d3501ee043a5f649e17 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.kanboard;
toStringAttrs = lib.mapAttrs (lib.const toString);
in
{
meta.maintainers = with lib.maintainers; [ yzx9 ];
options.services.kanboard = {
enable = lib.mkEnableOption "Kanboard";
package = lib.mkPackageOption pkgs "kanboard" { };
dataDir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/kanboard";
description = "Default data folder for Kanboard.";
example = "/mnt/kanboard";
};
user = lib.mkOption {
type = lib.types.str;
default = "kanboard";
description = "User under which Kanboard runs.";
};
group = lib.mkOption {
type = lib.types.str;
default = "kanboard";
description = "Group under which Kanboard runs.";
};
settings = lib.mkOption {
type =
with lib.types;
attrsOf (oneOf [
str
int
bool
]);
default = { };
description = ''
Customize the default settings, refer to <https://github.com/kanboard/kanboard/blob/main/config.default.php>
for details on supported values.
'';
};
# Nginx
domain = lib.mkOption {
type = lib.types.str;
default = "kanboard";
description = "FQDN for the Kanboard instance.";
example = "kanboard.example.org";
};
nginx = lib.mkOption {
type = lib.types.nullOr (
lib.types.submodule (import ../web-servers/nginx/vhost-options.nix { inherit config lib; })
);
default = { };
description = ''
With this option, you can customize an NGINX virtual host which already
has sensible defaults for Kanboard. Set to `{ }` if you do not need any
customization for the virtual host. If enabled, then by default, the
{option}`serverName` is `''${domain}`. If this is set to null (the
default), no NGINX virtual host will be configured.
'';
example = lib.literalExpression ''
{
enableACME = true;
forceSSL = true;
}
'';
};
phpfpm.settings = lib.mkOption {
type =
with lib.types;
attrsOf (oneOf [
int
str
bool
]);
default = { };
description = ''
Options for kanboard's PHPFPM pool.
'';
};
};
config = lib.mkIf cfg.enable {
users = {
users = lib.mkIf (cfg.user == "kanboard") {
kanboard = {
isSystemUser = true;
group = cfg.group;
home = cfg.dataDir;
createHome = true;
};
};
groups = lib.mkIf (cfg.group == "kanboard") {
kanboard = { };
};
};
services.phpfpm.pools.kanboard = {
user = cfg.user;
group = cfg.group;
settings = lib.mkMerge [
{
"pm" = "dynamic";
"php_admin_value[error_log]" = "stderr";
"php_admin_flag[log_errors]" = true;
"listen.owner" = config.services.nginx.user;
"catch_workers_output" = true;
"pm.max_children" = "32";
"pm.start_servers" = "2";
"pm.min_spare_servers" = "2";
"pm.max_spare_servers" = "4";
"pm.max_requests" = "500";
}
cfg.phpfpm.settings
];
phpEnv = lib.mkMerge [
{ DATA_DIR = cfg.dataDir; }
(toStringAttrs cfg.settings)
];
};
services.nginx = lib.mkIf (cfg.nginx != null) {
enable = lib.mkDefault true;
virtualHosts."${cfg.domain}" = lib.mkMerge [
{
root = lib.mkForce "${cfg.package}/share/kanboard";
locations."/".extraConfig = ''
rewrite ^ /index.php;
'';
locations."~ \\.php$".extraConfig = ''
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:${config.services.phpfpm.pools.kanboard.socket};
include ${config.services.nginx.package}/conf/fastcgi.conf;
include ${config.services.nginx.package}/conf/fastcgi_params;
'';
locations."~ \\.(js|css|ttf|woff2?|png|jpe?g|svg)$".extraConfig = ''
add_header Cache-Control "public, max-age=15778463";
add_header X-Content-Type-Options nosniff;
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
add_header Referrer-Policy no-referrer;
access_log off;
'';
extraConfig = ''
try_files $uri /index.php;
'';
}
cfg.nginx
];
};
};
}
|