Loading nixos/modules/services/misc/autobrr.nix +54 −23 Original line number Diff line number Diff line Loading @@ -8,8 +8,7 @@ let cfg = config.services.autobrr; configFormat = pkgs.formats.toml { }; configTemplate = configFormat.generate "autobrr.toml" cfg.settings; templaterCmd = ''${lib.getExe pkgs.dasel} put -f '${configTemplate}' -v "$(${config.systemd.package}/bin/systemd-creds cat sessionSecret)" -o %S/autobrr/config.toml "sessionSecret"''; configFile = configFormat.generate "autobrr.toml" cfg.settings; in { options = { Loading @@ -28,13 +27,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 = '' Loading @@ -61,7 +78,17 @@ in } ]; systemd.services.autobrr = { systemd = { tmpfiles.settings = { "10-autobrr" = { # DynamicUser uses /var/lib/private/ "/var/lib/private/autobrr/config.toml"."L+" = { argument = "${configFile}"; }; }; }; services.autobrr = { description = "Autobrr"; after = [ "syslog.target" Loading @@ -69,18 +96,22 @@ in ]; wants = [ "network-online.target" ]; wantedBy = [ "multi-user.target" ]; restartTriggers = [ configFile ]; serviceConfig = { Type = "simple"; DynamicUser = true; LoadCredential = "sessionSecret:${cfg.secretFile}"; Environment = [ "AUTOBRR__SESSION_SECRET_FILE=%d/sessionSecret" ]; StateDirectory = "autobrr"; ExecStartPre = "${lib.getExe pkgs.bash} -c '${templaterCmd}'"; ExecStart = "${lib.getExe cfg.package} --config %S/autobrr"; Restart = "on-failure"; }; }; }; networking.firewall = lib.mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.settings.port ]; }; }; meta.maintainers = with lib.maintainers; [ av-gal ]; } nixos/tests/autobrr.nix +32 −8 Original line number Diff line number Diff line Loading @@ -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 = '' 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(7474) machine.succeed("curl --fail http://localhost:7474/") 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) ''; } pkgs/by-name/au/autobrr/package.nix +9 −5 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ fetchFromGitHub, stdenvNoCC, nix-update-script, nixosTests, nodejs, pnpm_10, fetchPnpmDeps, Loading Loading @@ -86,12 +87,15 @@ buildGoModule (finalAttrs: { versionCheckProgram = "${placeholder "out"}/bin/autobrrctl"; versionCheckProgramArg = "version"; passthru.updateScript = nix-update-script { passthru = { updateScript = nix-update-script { extraArgs = [ "--subpackage" "autobrr-web" ]; }; tests.testService = nixosTests.autobrr; }; meta = { description = "Modern, easy to use download automation for torrents and usenet"; Loading Loading
nixos/modules/services/misc/autobrr.nix +54 −23 Original line number Diff line number Diff line Loading @@ -8,8 +8,7 @@ let cfg = config.services.autobrr; configFormat = pkgs.formats.toml { }; configTemplate = configFormat.generate "autobrr.toml" cfg.settings; templaterCmd = ''${lib.getExe pkgs.dasel} put -f '${configTemplate}' -v "$(${config.systemd.package}/bin/systemd-creds cat sessionSecret)" -o %S/autobrr/config.toml "sessionSecret"''; configFile = configFormat.generate "autobrr.toml" cfg.settings; in { options = { Loading @@ -28,13 +27,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 = '' Loading @@ -61,7 +78,17 @@ in } ]; systemd.services.autobrr = { systemd = { tmpfiles.settings = { "10-autobrr" = { # DynamicUser uses /var/lib/private/ "/var/lib/private/autobrr/config.toml"."L+" = { argument = "${configFile}"; }; }; }; services.autobrr = { description = "Autobrr"; after = [ "syslog.target" Loading @@ -69,18 +96,22 @@ in ]; wants = [ "network-online.target" ]; wantedBy = [ "multi-user.target" ]; restartTriggers = [ configFile ]; serviceConfig = { Type = "simple"; DynamicUser = true; LoadCredential = "sessionSecret:${cfg.secretFile}"; Environment = [ "AUTOBRR__SESSION_SECRET_FILE=%d/sessionSecret" ]; StateDirectory = "autobrr"; ExecStartPre = "${lib.getExe pkgs.bash} -c '${templaterCmd}'"; ExecStart = "${lib.getExe cfg.package} --config %S/autobrr"; Restart = "on-failure"; }; }; }; networking.firewall = lib.mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.settings.port ]; }; }; meta.maintainers = with lib.maintainers; [ av-gal ]; }
nixos/tests/autobrr.nix +32 −8 Original line number Diff line number Diff line Loading @@ -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 = '' 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(7474) machine.succeed("curl --fail http://localhost:7474/") 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) ''; }
pkgs/by-name/au/autobrr/package.nix +9 −5 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ fetchFromGitHub, stdenvNoCC, nix-update-script, nixosTests, nodejs, pnpm_10, fetchPnpmDeps, Loading Loading @@ -86,12 +87,15 @@ buildGoModule (finalAttrs: { versionCheckProgram = "${placeholder "out"}/bin/autobrrctl"; versionCheckProgramArg = "version"; passthru.updateScript = nix-update-script { passthru = { updateScript = nix-update-script { extraArgs = [ "--subpackage" "autobrr-web" ]; }; tests.testService = nixosTests.autobrr; }; meta = { description = "Modern, easy to use download automation for torrents and usenet"; Loading