-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
233 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
{ | ||
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."; | ||
}; | ||
|
||
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; | ||
forceHttps = true; | ||
} | ||
''; | ||
}; | ||
|
||
phpfpm.settings = lib.mkOption { | ||
type = | ||
with lib.types; | ||
attrsOf (oneOf [ | ||
int | ||
str | ||
bool | ||
]); | ||
default = { | ||
"pm" = "dynamic"; | ||
"php_admin_value[error_log]" = "stderr"; | ||
"php_admin_flag[log_errors]" = true; | ||
"listen.owner" = "nginx"; | ||
"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"; | ||
}; | ||
|
||
description = '' | ||
Options for kanboard's PHPFPM pool. | ||
''; | ||
}; | ||
}; | ||
|
||
config = lib.mkIf cfg.enable { | ||
users.users.${cfg.user} = lib.mapAttrs (_: lib.mkDefault) { | ||
isSystemUser = true; | ||
group = config.services.nginx.group; | ||
home = cfg.dataDir; | ||
createHome = true; | ||
}; | ||
|
||
services.phpfpm.pools.kanboard = { | ||
user = cfg.user; | ||
group = config.services.nginx.group; | ||
|
||
inherit (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 [ | ||
(lib.mapAttrs (_: lib.mkDefault) { | ||
root = "${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-XSS-Protection "1; mode=block"; | ||
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 | ||
]; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import ../make-test-python.nix ( | ||
{ pkgs, ... }: | ||
|
||
{ | ||
name = "kanboard"; | ||
meta.maintainers = with pkgs.lib.maintainers; [ yzx9 ]; | ||
|
||
nodes = { | ||
machine = | ||
{ ... }: | ||
|
||
{ | ||
services.kanboard = { | ||
enable = true; | ||
}; | ||
}; | ||
}; | ||
|
||
testScript = '' | ||
start_all() | ||
machine.wait_for_unit("nginx.service") | ||
machine.wait_for_unit("phpfpm-kanboard.service") | ||
machine.wait_for_open_port(80) | ||
machine.succeed("curl -k --fail http://localhost", timeout=10) | ||
''; | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
lib, | ||
stdenvNoCC, | ||
fetchFromGitHub, | ||
nixosTests, | ||
nix-update-script, | ||
}: | ||
|
||
stdenvNoCC.mkDerivation (attrs: { | ||
pname = "kanboard"; | ||
version = "1.2.42"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "kanboard"; | ||
repo = "kanboard"; | ||
rev = "refs/tags/v${attrs.version}"; | ||
hash = "sha256-/Unxl9Vh9pEWjO89sSviGGPFzUwxdb1mbOfpTFTyRL0="; | ||
}; | ||
|
||
dontBuild = true; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
mkdir -p $out/share/kanboard | ||
cp -rv . $out/share/kanboard | ||
runHook postInstall | ||
''; | ||
|
||
passthru = { | ||
updateScript = nix-update-script { }; | ||
tests = { | ||
basic-frunctionality = nixosTests.kanboard; | ||
}; | ||
}; | ||
|
||
meta = { | ||
description = "Kanban project management software"; | ||
homepage = "https://kanboard.org"; | ||
license = lib.licenses.mit; | ||
maintainers = with lib.maintainers; [ yzx9 ]; | ||
}; | ||
}) |