Commit b6b90562 authored by Ayman Bagabas's avatar Ayman Bagabas Committed by Bjørn Forsman
Browse files

calibre-server: add extraFlags and openFirewall options

This allows users to pass extra flags to the calibre-server command and
open the necessary ports in the firewall for the Calibre Server API.
parent 474d515b
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ let
      "--port" = cfg.port;
      "--auth-mode" = cfg.auth.mode;
      "--userdb" = cfg.auth.userDb;
    }) ++ [(lib.optionalString (cfg.auth.enable == true) "--enable-auth")])
    }) ++ [ (lib.optionalString (cfg.auth.enable == true) "--enable-auth") ] ++ cfg.extraFlags)
  );
in

@@ -42,6 +42,15 @@ in
        '';
      };

      extraFlags = lib.mkOption {
        type = lib.types.listOf lib.types.str;
        default = [ ];
        description = ''
          Extra flags to pass to the calibre-server command.
          See the [calibre-server documentation](${generatedDocumentationLink}) for details.
        '';
      };

      user = lib.mkOption {
        type = lib.types.str;
        default = "calibre-server";
@@ -73,6 +82,13 @@ in
        '';
      };

      openFirewall = lib.mkOption {
        type = lib.types.bool;
        default = false;
        description =
          "Open ports in the firewall for the Calibre Server web interface.";
      };

      auth = {
        enable = lib.mkOption {
          type = lib.types.bool;
@@ -137,6 +153,9 @@ in
      };
    };

    networking.firewall =
      lib.mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.port ]; };

  };

  meta.maintainers = with lib.maintainers; [ gaelreyrol ];