about summary refs log tree commit diff
path: root/modules/services/vikunja.nix
blob: c54870b89edeb1876eebf7413ca20fb6f3e9cd37 (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
{ config, lib, ... }:

with lib;
let
  cfg = config.modules.services.vikunja;
in
{
  options.modules.services.vikunja = {
    enable = mkEnableOption "vikunja";
    domain = mkOption { type = types.str; };
    realHost = mkOption { type = types.str; };
  };

  config = mkIf cfg.enable {
    services.vikunja = {
      enable = true;
      frontendHostname = cfg.realHost;
      frontendScheme = "https";

      settings = {
        service.enableregistration = false;
      };

      database = {
        type = "postgres";
        user = "vikunja";
        database = "vikunja";
        host = "/run/postgresql";
      };
    };

    services.postgresql.enable = true;
    services.postgresql.ensureDatabases = [ "vikunja" ];
    services.postgresql.ensureUsers = [
      {
        name = "vikunja";
        ensureDBOwnership = true;
      }
    ];

    modules.persistence.directories = [
      "/var/lib/private/vikunja"
    ];

    services.nginx.virtualHosts.${cfg.realHost} = {
      forceSSL = true;
      useACMEHost = cfg.domain;
    };
  };
}