2023-05-13 20:18:58 +02:00
|
|
|
# Todo and kanban app
|
|
|
|
{ config, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.my.services.vikunja;
|
|
|
|
subdomain = "todo";
|
|
|
|
vikunjaDomain = "${subdomain}.${config.networking.domain}";
|
|
|
|
socketPath = "/run/vikunja/vikunja.socket";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.services.vikunja = with lib; {
|
|
|
|
enable = mkEnableOption "Vikunja todo app";
|
|
|
|
|
|
|
|
mail = {
|
|
|
|
enable = mkEnableOption {
|
|
|
|
description = "mailer configuration";
|
|
|
|
};
|
|
|
|
|
|
|
|
configFile = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "/run/secrets/vikunja-mail-config.env";
|
|
|
|
description = "Configuration for the mailer connection, using environment variables.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.vikunja = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
frontendScheme = "https";
|
|
|
|
frontendHostname = vikunjaDomain;
|
|
|
|
|
|
|
|
database = {
|
|
|
|
type = "postgres";
|
|
|
|
user = "vikunja";
|
|
|
|
database = "vikunja";
|
|
|
|
host = "/run/postgresql";
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
service = {
|
|
|
|
# Only allow registration of users through the CLI
|
|
|
|
enableregistration = false;
|
2024-09-27 15:48:26 +02:00
|
|
|
# Use the host's timezone
|
2023-05-13 20:18:58 +02:00
|
|
|
timezone = config.time.timeZone;
|
|
|
|
# Use UNIX socket for serving the API
|
|
|
|
unixsocket = socketPath;
|
|
|
|
unixsocketmode = "0o660";
|
|
|
|
};
|
|
|
|
|
|
|
|
mailer = {
|
|
|
|
enabled = cfg.mail.enable;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
environmentFiles = lib.optional cfg.mail.enable cfg.mail.configFile;
|
|
|
|
};
|
|
|
|
|
|
|
|
# This is a weird setup
|
2023-12-25 19:25:08 +01:00
|
|
|
my.services.nginx.virtualHosts = {
|
2023-12-25 19:42:20 +01:00
|
|
|
${subdomain} = {
|
2024-03-09 21:49:12 +01:00
|
|
|
socket = socketPath;
|
2023-12-25 19:25:08 +01:00
|
|
|
};
|
|
|
|
};
|
2023-05-13 20:18:58 +02:00
|
|
|
|
2024-03-09 21:49:12 +01:00
|
|
|
systemd.services.vikunja = {
|
2023-05-13 20:18:58 +02:00
|
|
|
serviceConfig = {
|
|
|
|
# Use a system user to simplify using the CLI
|
|
|
|
DynamicUser = lib.mkForce false;
|
|
|
|
# Set the user for postgres authentication
|
|
|
|
User = "vikunja";
|
|
|
|
# Create /run/vikunja/ to serve the UNIX socket
|
|
|
|
RuntimeDirectory = "vikunja";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users.vikunja = {
|
|
|
|
description = "Vikunja Service";
|
|
|
|
group = "vikunja";
|
|
|
|
isSystemUser = true;
|
|
|
|
};
|
|
|
|
users.groups.vikunja = { };
|
|
|
|
|
|
|
|
# Allow nginx to access the UNIX socket
|
|
|
|
users.users.nginx.extraGroups = [ "vikunja" ];
|
|
|
|
|
|
|
|
services.postgresql = {
|
|
|
|
ensureDatabases = [ "vikunja" ];
|
|
|
|
ensureUsers = [
|
|
|
|
{
|
|
|
|
name = "vikunja";
|
2023-11-21 00:18:29 +01:00
|
|
|
ensureDBOwnership = true;
|
2023-05-13 20:18:58 +02:00
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
my.services.backup = {
|
|
|
|
paths = [
|
|
|
|
config.services.vikunja.settings.files.basepath
|
|
|
|
];
|
|
|
|
};
|
2024-09-24 12:44:09 +02:00
|
|
|
|
2021-11-03 14:43:16 +01:00
|
|
|
my.system.persist.directories = [
|
|
|
|
config.services.vikunja.settings.files.basepath
|
|
|
|
];
|
|
|
|
|
2024-09-24 12:44:09 +02:00
|
|
|
# NOTE: unfortunately vikunja does not log connection failures for fail2ban
|
2023-05-13 20:18:58 +02:00
|
|
|
};
|
|
|
|
}
|