about summary refs log tree commit diff
path: root/nixos/modules/services/web-apps
diff options
context:
space:
mode:
authornuko <nuko@shimeji.cafe>2024-03-01 15:09:27 +1300
committernuko <nuko@shimeji.cafe>2024-03-01 15:13:06 +1300
commit502f34f3e09ccf06443b0a1de269a584fb424693 (patch)
treeea28342c111735f3c0b194c9013bcf750eee5d5a /nixos/modules/services/web-apps
parent2f2208aca6f74f3a8894bbb0f080d9b221768ac3 (diff)
downloadnixlib-502f34f3e09ccf06443b0a1de269a584fb424693.tar
nixlib-502f34f3e09ccf06443b0a1de269a584fb424693.tar.gz
nixlib-502f34f3e09ccf06443b0a1de269a584fb424693.tar.bz2
nixlib-502f34f3e09ccf06443b0a1de269a584fb424693.tar.lz
nixlib-502f34f3e09ccf06443b0a1de269a584fb424693.tar.xz
nixlib-502f34f3e09ccf06443b0a1de269a584fb424693.tar.zst
nixlib-502f34f3e09ccf06443b0a1de269a584fb424693.zip
nixos/komga: rfcfmt, rm mdDoc & toplvl with lib
Diffstat (limited to 'nixos/modules/services/web-apps')
-rw-r--r--nixos/modules/services/web-apps/komga.nix108
1 files changed, 52 insertions, 56 deletions
diff --git a/nixos/modules/services/web-apps/komga.nix b/nixos/modules/services/web-apps/komga.nix
index 31f475fc7b04..39b580818aa6 100644
--- a/nixos/modules/services/web-apps/komga.nix
+++ b/nixos/modules/services/web-apps/komga.nix
@@ -1,99 +1,95 @@
-{ config, pkgs, lib, ... }:
-
-with lib;
+{
+  config,
+  pkgs,
+  lib,
+  ...
+}:
 
 let
   cfg = config.services.komga;
-
-in {
+  inherit (lib) mkOption mkEnableOption maintainers;
+  inherit (lib.types) port str bool;
+in
+{
   options = {
     services.komga = {
-      enable = mkEnableOption (lib.mdDoc "Komga, a free and open source comics/mangas media server");
+      enable = mkEnableOption "Komga, a free and open source comics/mangas media server";
 
       port = mkOption {
-        type = types.port;
+        type = port;
         default = 8080;
-        description = lib.mdDoc ''
-          The port that Komga will listen on.
-        '';
+        description = "The port that Komga will listen on.";
       };
 
       user = mkOption {
-        type = types.str;
+        type = str;
         default = "komga";
-        description = lib.mdDoc ''
-          User account under which Komga runs.
-        '';
+        description = "User account under which Komga runs.";
       };
 
       group = mkOption {
-        type = types.str;
+        type = str;
         default = "komga";
-        description = lib.mdDoc ''
-          Group under which Komga runs.
-        '';
+        description = "Group under which Komga runs.";
       };
 
       stateDir = mkOption {
-        type = types.str;
+        type = str;
         default = "/var/lib/komga";
-        description = lib.mdDoc ''
-          State and configuration directory Komga will use.
-        '';
+        description = "State and configuration directory Komga will use.";
       };
 
       openFirewall = mkOption {
-        type = types.bool;
+        type = bool;
         default = false;
-        description = lib.mdDoc ''
-          Whether to open the firewall for the port in {option}`services.komga.port`.
-        '';
+        description = "Whether to open the firewall for the port in {option}`services.komga.port`.";
       };
     };
   };
 
-  config = mkIf cfg.enable {
+  config =
+    let
+      inherit (lib) mkIf;
+    in
+    mkIf cfg.enable {
 
-    networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];
+      networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];
 
-    users.groups = mkIf (cfg.group == "komga") {
-      komga = {};
-    };
+      users.groups = mkIf (cfg.group == "komga") { komga = { }; };
 
-    users.users = mkIf (cfg.user == "komga") {
-      komga = {
-        group = cfg.group;
-        home = cfg.stateDir;
-        description = "Komga Daemon user";
-        isSystemUser = true;
+      users.users = mkIf (cfg.user == "komga") {
+        komga = {
+          group = cfg.group;
+          home = cfg.stateDir;
+          description = "Komga Daemon user";
+          isSystemUser = true;
+        };
       };
-    };
 
-    systemd.services.komga = {
-      environment = {
-        SERVER_PORT = builtins.toString cfg.port;
-        KOMGA_CONFIGDIR = cfg.stateDir;
-      };
+      systemd.services.komga = {
+        environment = {
+          SERVER_PORT = builtins.toString cfg.port;
+          KOMGA_CONFIGDIR = cfg.stateDir;
+        };
 
-      description = "Komga is a free and open source comics/mangas media server";
+        description = "Komga is a free and open source comics/mangas media server";
 
-      wantedBy = [ "multi-user.target" ];
-      wants = [ "network-online.target" ];
-      after = [ "network-online.target" ];
+        wantedBy = [ "multi-user.target" ];
+        wants = [ "network-online.target" ];
+        after = [ "network-online.target" ];
 
-      serviceConfig = {
-        User = cfg.user;
-        Group = cfg.group;
+        serviceConfig = {
+          User = cfg.user;
+          Group = cfg.group;
 
-        Type = "simple";
-        Restart = "on-failure";
-        ExecStart = "${pkgs.komga}/bin/komga";
+          Type = "simple";
+          Restart = "on-failure";
+          ExecStart = "${pkgs.komga}/bin/komga";
 
-        StateDirectory = mkIf (cfg.stateDir == "/var/lib/komga") "komga";
+          StateDirectory = mkIf (cfg.stateDir == "/var/lib/komga") "komga";
+        };
       };
-
     };
-  };
 
   meta.maintainers = with maintainers; [ govanify ];
 }