···
cfg = config.services.komga;
inherit (lib) mkOption mkEnableOption maintainers;
inherit (lib.types) port str bool;
13
+
settingsFormat = pkgs.formats.yaml { };
17
+
(lib.mkRenamedOptionModule
enable = mkEnableOption "Komga, a free and open source comics/mangas media server";
21
-
description = "The port that Komga will listen on.";
···
description = "State and configuration directory Komga will use.";
55
+
settings = lib.mkOption {
56
+
inherit (settingsFormat) type;
58
+
defaultText = lib.literalExpression ''
64
+
Komga configuration.
66
+
See [documentation](https://komga.org/docs/installation/configuration).
openFirewall = mkOption {
45
-
description = "Whether to open the firewall for the port in {option}`services.komga.port`.";
73
+
description = "Whether to open the firewall for the port in {option}`services.komga.settings.server.port`.";
···
inherit (lib) mkIf getExe;
85
+
assertion = (cfg.settings.komga.config-dir or cfg.stateDir) == cfg.stateDir;
86
+
message = "You must use the `services.komga.stateDir` option to properly configure `komga.config-dir`.";
90
+
services.komga.settings = {
91
+
server.port = lib.mkDefault 8080;
networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];
···
107
+
systemd.tmpfiles.settings."10-komga" = {
108
+
${cfg.stateDir}.d = {
109
+
inherit (cfg) user group;
111
+
"${cfg.stateDir}/application.yml"."L+" = {
112
+
argument = builtins.toString (settingsFormat.generate "application.yml" cfg.settings);
systemd.services.komga = {
71
-
SERVER_PORT = builtins.toString cfg.port;
KOMGA_CONFIGDIR = cfg.stateDir;