Skip to content

Commit

Permalink
kanboard: remove with
Browse files Browse the repository at this point in the history
  • Loading branch information
yzx9 committed Nov 29, 2024
1 parent f57428b commit fd3b7e2
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 50 deletions.
2 changes: 1 addition & 1 deletion nixos/doc/manual/release-notes/rl-2505.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->

- [KanBoard](https://github.com/kanboard/kanboard) is project management software that focuses on the Kanban methodology.
- [KanBoard](https://github.com/kanboard/kanboard), a project management tool that focuses on the Kanban methodology. Available as [services.kanboard](#opt-services.kanboard.enable).

- [Kimai](https://www.kimai.org/), a web-based multi-user time-tracking application. Available as [services.kimai](option.html#opt-services.kimai).

Expand Down
109 changes: 64 additions & 45 deletions nixos/modules/services/web-apps/kanboard.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@
let
cfg = config.services.kanboard;

toStringAttrs = attrs: lib.attrsets.mapAttrs (k: v: toString v) attrs;
toStringAttrs = lib.mapAttrs (lib.const toString);
in
{
meta.maintainers = with lib.maintainers; [ yzx9 ];

options.services.kanboard = with lib; {
enable = mkEnableOption "Kanboard";
options.services.kanboard = {
enable = lib.mkEnableOption "Kanboard";

package = mkPackageOption pkgs "kanboard" { };
package = lib.mkPackageOption pkgs "kanboard" { };

dataDir = mkOption {
type = types.str;
dataDir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/kanboard";
description = "Default data folder for Kanboard.";
example = "/mnt/kanboard";
};

user = mkOption {
type = types.str;
user = lib.mkOption {
type = lib.types.str;
default = "kanboard";
description = "User under which Kanboard runs.";
};

settings = mkOption {
settings = lib.mkOption {
type =
with types;
with lib.types;
attrsOf (oneOf [
str
int
Expand All @@ -49,10 +49,28 @@ in
};

# Nginx
virtualHost = mkOption {
domain = lib.mkOption {
type = lib.types.str;
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 = null;
description = ''
FQDN for the kanboard instance.
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;
}
'';
};

Expand Down Expand Up @@ -97,41 +115,42 @@ in

inherit (cfg.phpfpm) settings;

phpEnv = {
DATA_DIR = cfg.dataDir;
} // toStringAttrs cfg.settings;
phpEnv = lib.mkMerge [
{ DATA_DIR = cfg.dataDir; }
(toStringAttrs cfg.settings)
];
};

services.nginx = {
enable = true;
virtualHosts."${cfg.virtualHost}" = {
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;
'';
};
services.nginx = lib.mkIf (cfg.nginx != null) {
enable = lib.mkDefault true;
virtualHosts."${cfg.domain}" = lib.mkMerge [
{
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
];
};
};
}
8 changes: 4 additions & 4 deletions pkgs/by-name/ka/kanboard/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ stdenvNoCC.mkDerivation (attrs: {
src = fetchFromGitHub {
owner = "kanboard";
repo = "kanboard";
rev = "v${attrs.version}";
rev = "refs/tags/v${attrs.version}";
hash = "sha256-/Unxl9Vh9pEWjO89sSviGGPFzUwxdb1mbOfpTFTyRL0=";
};

Expand All @@ -25,10 +25,10 @@ stdenvNoCC.mkDerivation (attrs: {

passthru.updateScript = nix-update-script { };

meta = with lib; {
meta = {
description = "Kanban project management software";
homepage = "https://kanboard.org";
license = licenses.mit;
maintainers = with maintainers; [ yzx9 ];
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ yzx9 ];
};
})

0 comments on commit fd3b7e2

Please sign in to comment.