9 cfg = config.services.komga;
10 inherit (lib) mkOption mkEnableOption maintainers;
11 inherit (lib.types) port str bool;
16 enable = mkEnableOption "Komga, a free and open source comics/mangas media server";
21 description = "The port that Komga will listen on.";
27 description = "User account under which Komga runs.";
33 description = "Group under which Komga runs.";
38 default = "/var/lib/komga";
39 description = "State and configuration directory Komga will use.";
42 openFirewall = mkOption {
45 description = "Whether to open the firewall for the port in {option}`services.komga.port`.";
52 inherit (lib) mkIf getExe;
56 networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];
58 users.groups = mkIf (cfg.group == "komga") { komga = { }; };
60 users.users = mkIf (cfg.user == "komga") {
64 description = "Komga Daemon user";
69 systemd.services.komga = {
71 SERVER_PORT = builtins.toString cfg.port;
72 KOMGA_CONFIGDIR = cfg.stateDir;
75 description = "Komga is a free and open source comics/mangas media server";
77 wantedBy = [ "multi-user.target" ];
78 wants = [ "network-online.target" ];
79 after = [ "network-online.target" ];
86 Restart = "on-failure";
87 ExecStart = getExe pkgs.komga;
89 StateDirectory = mkIf (cfg.stateDir == "/var/lib/komga") "komga";
92 NoNewPrivileges = true;
93 CapabilityBoundingSet = "";
94 SystemCallFilter = [ "@system-service" ];
95 ProtectSystem = "full";
97 ProtectProc = "invisible";
101 PrivateDevices = true;
102 ProtectHostname = true;
103 ProtectKernelTunables = true;
104 RestrictAddressFamilies = [
109 LockPersonality = true;
110 RestrictNamespaces = true;
111 ProtectKernelLogs = true;
112 ProtectControlGroups = true;
113 ProtectKernelModules = true;
114 SystemCallArchitectures = "native";
115 RestrictSUIDSGID = true;
116 RestrictRealtime = true;
121 meta.maintainers = with maintainers; [ govanify ];