nixos/autobrr: add options to settings submodule

This commit is contained in:
bas
2026-04-09 12:12:42 +02:00
parent 3707d70bcb
commit 562440897a
2 changed files with 55 additions and 13 deletions

View File

@@ -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 = ''

View File

@@ -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)
'';
}