From b6b90562f7698ae015471fc4ff5d45399cc6622a Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Wed, 23 Oct 2024 09:55:28 -0400 Subject: [PATCH] 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. --- .../modules/services/misc/calibre-server.nix | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/misc/calibre-server.nix b/nixos/modules/services/misc/calibre-server.nix index 5fa3c11a48aa..160a1c1e53c4 100644 --- a/nixos/modules/services/misc/calibre-server.nix +++ b/nixos/modules/services/misc/calibre-server.nix @@ -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 ];