diff --git a/nixos/modules/services/misc/autobrr.nix b/nixos/modules/services/misc/autobrr.nix index 466ffe70cf20..264345792be1 100644 --- a/nixos/modules/services/misc/autobrr.nix +++ b/nixos/modules/services/misc/autobrr.nix @@ -28,13 +28,31 @@ in }; settings = lib.mkOption { - type = lib.types.submodule { freeformType = configFormat.type; }; - default = { - host = "127.0.0.1"; - port = 7474; - checkForUpdates = true; + type = lib.types.submodule { + freeformType = configFormat.type; + options = { + host = lib.mkOption { + type = lib.types.str; + default = "127.0.0.1"; + description = "The host address autobrr listens on."; + }; + + port = lib.mkOption { + type = lib.types.port; + default = 7474; + description = "The port autobrr listens on."; + }; + + checkForUpdates = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Whether autobrr needs to check for updates."; + }; + }; }; + default = { }; example = { + port = 7654; logLevel = "DEBUG"; }; description = '' diff --git a/nixos/tests/autobrr.nix b/nixos/tests/autobrr.nix index c6b820057272..96f62b892dbd 100644 --- a/nixos/tests/autobrr.nix +++ b/nixos/tests/autobrr.nix @@ -6,18 +6,42 @@ nodes.machine = { pkgs, ... }: + let + # We create this secret in the Nix store (making it readable by everyone). + # DO NOT DO THIS OUTSIDE OF TESTS!! + testSecretFile = pkgs.writeText "session_secret" "not-secret"; + in { services.autobrr = { enable = true; - # We create this secret in the Nix store (making it readable by everyone). - # DO NOT DO THIS OUTSIDE OF TESTS!! - secretFile = pkgs.writeText "session_secret" "not-secret"; + secretFile = testSecretFile; + }; + + # Use port other than default to test if settings options work. + specialisation.settingsPort.configuration = { + services.autobrr = { + enable = true; + secretFile = testSecretFile; + settings.port = 7777; + }; }; }; - testScript = '' - machine.wait_for_unit("autobrr.service") - machine.wait_for_open_port(7474) - machine.succeed("curl --fail http://localhost:7474/") - ''; + testScript = + { nodes, ... }: + let + settingsPort = "${nodes.machine.system.build.toplevel}/specialisation/settingsPort"; + in + # python + '' + def test_webui(port): + machine.wait_for_unit("autobrr.service") + machine.wait_for_open_port(port) + machine.wait_until_succeeds(f"curl --fail http://localhost:{port}") + + test_webui(7474) + + machine.succeed("${settingsPort}/bin/switch-to-configuration test") + test_webui(7777) + ''; }