1 { pkgs, lib, config, ... }:
6 cfg = config.services.vikunja;
7 format = pkgs.formats.yaml {};
8 configFile = format.generate "config.yaml" cfg.settings;
9 useMysql = cfg.database.type == "mysql";
10 usePostgresql = cfg.database.type == "postgres";
13 (mkRemovedOptionModule [ "services" "vikunja" "setupNginx" ] "services.vikunja no longer supports the automatic set up of a nginx virtual host. Set up your own webserver config with a proxy pass to the vikunja service.")
16 options.services.vikunja = with lib; {
17 enable = mkEnableOption "vikunja service";
18 package = mkPackageOption pkgs "vikunja" { };
19 environmentFiles = mkOption {
20 type = types.listOf types.path;
23 List of environment files set in the vikunja systemd service.
24 For example passwords should be set in one of these files.
27 frontendScheme = mkOption {
28 type = types.enum [ "http" "https" ];
30 Whether the site is available via http or https.
33 frontendHostname = mkOption {
35 description = "The Hostname under which the frontend is running.";
40 description = "The TCP port exposed by the API.";
47 Vikunja configuration. Refer to
48 <https://vikunja.io/docs/config-options/>
49 for details on supported values.
54 type = types.enum [ "sqlite" "mysql" "postgres" ];
57 description = "Database engine to use.";
61 default = "localhost";
62 description = "Database host address. Can also be a socket.";
67 description = "Database user.";
72 description = "Database name.";
76 default = "/var/lib/vikunja/vikunja.db";
77 description = "Path to the sqlite3 database file.";
81 config = lib.mkIf cfg.enable {
82 services.vikunja.settings = {
84 inherit (cfg.database) type host user database path;
87 interface = ":${toString cfg.port}";
88 frontendurl = "${cfg.frontendScheme}://${cfg.frontendHostname}/";
91 basepath = "/var/lib/vikunja/files";
95 systemd.services.vikunja = {
96 description = "vikunja";
97 after = [ "network.target" ] ++ lib.optional usePostgresql "postgresql.service" ++ lib.optional useMysql "mysql.service";
98 wantedBy = [ "multi-user.target" ];
99 path = [ cfg.package ];
100 restartTriggers = [ configFile ];
105 StateDirectory = "vikunja";
106 ExecStart = "${cfg.package}/bin/vikunja";
108 EnvironmentFile = cfg.environmentFiles;
112 environment.etc."vikunja/config.yaml".source = configFile;
114 environment.systemPackages = [
115 cfg.package # for admin `vikunja` CLI