Skip to content

Commit

Permalink
nixos/autobrr: init
Browse files Browse the repository at this point in the history
  • Loading branch information
av-gal committed Nov 25, 2024
1 parent 6373fcf commit 7247996
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2505.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

- [Kimai](https://www.kimai.org/), a web-based multi-user time-tracking application. Available as [services.kimai](option.html#opt-services.kimai).

- [autobrr](https://autobrr.com), a modern download automation tool for torrents and usenets. Available as [services.autobrr](#opt-services.autobrr.enable).

- [Amazon CloudWatch Agent](https://github.com/aws/amazon-cloudwatch-agent), the official telemetry collector for AWS CloudWatch and AWS X-Ray. Available as [services.amazon-cloudwatch-agent](#opt-services.amazon-cloudwatch-agent.enable).

<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@
./services/misc/anki-sync-server.nix
./services/misc/apache-kafka.nix
./services/misc/atuin.nix
./services/misc/autobrr.nix
./services/misc/autofs.nix
./services/misc/autorandr.nix
./services/misc/autosuspend.nix
Expand Down
71 changes: 71 additions & 0 deletions nixos/modules/services/misc/autobrr.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
config,
pkgs,
lib,
...
}:

with lib;

let
cfg = config.services.autobrr;
configFormat = pkgs.formats.toml { };
configFile = configFormat.generate "autobrr.toml" cfg.settings;
in
{
options = {
services.autobrr = {
enable = mkEnableOption "Autobrr";

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

package = mkPackageOption pkgs "autobrr" { };

settings = lib.mkOption {
type = lib.types.submodule { freeformType = configFormat.type; };
default = {
host = "127.0.0.1";
port = "7474";
checkForUpdates = true;
sessionSecret = "not-sure-how-to-store-this-safely";
};
example = {
logLevel = "DEBUG";
};
description = ''
Autobrr configuration options.
Refer to <https://autobrr.com/configuration/autobrr>
for a full list.
'';
};
};
};

config = mkIf cfg.enable {
systemd.services.autobrr = {
description = "Autobrr";
after = [
"syslog.target"
"network-online.target"
];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];

serviceConfig = {
Type = "simple";
DynamicUser = true;
StateDirectory = "autobrr";
StateDirectoryMode = "0700";
ExecStart = "${pkgs.autobrr}/bin/autobrr --config '${configFile}'";
Restart = "on-failure";
};
};

networking.firewall = mkIf cfg.openFirewall { allowedTCPPorts = [ 7575 ]; };
};
}
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ in {
audiobookshelf = handleTest ./audiobookshelf.nix {};
auth-mysql = handleTest ./auth-mysql.nix {};
authelia = handleTest ./authelia.nix {};
autobrr = handleTest ./autobrr.nix {};
avahi = handleTest ./avahi.nix {};
avahi-with-resolved = handleTest ./avahi.nix { networkd = true; };
ayatana-indicators = runTest ./ayatana-indicators.nix;
Expand Down
20 changes: 20 additions & 0 deletions nixos/tests/autobrr.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import ./make-test-python.nix (
{ lib, ... }:

{
name = "autobrr";
meta.maintainers = with lib.maintainers; [ av-gal ];

nodes.machine =
{ pkgs, ... }:
{
services.autobrr.enable = true;
};

testScript = ''
machine.wait_for_unit("autobrr.service")
machine.wait_for_open_port(7474)
machine.succeed("curl --fail http://localhost:7474/")
'';
}
)

0 comments on commit 7247996

Please sign in to comment.