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 Feb 9, 2024
1 parent 1157014 commit f8fbc72
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2405.section.md
Expand Up @@ -79,6 +79,8 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m

- [RustDesk](https://rustdesk.com), a full-featured open source remote control alternative for self-hosting and security with minimal configuration. Alternative to TeamViewer.

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

- [systemd-lock-handler](https://git.sr.ht/~whynothugo/systemd-lock-handler/), a bridge between logind D-Bus events and systemd targets. Available as [services.systemd-lock-handler.enable](#opt-services.systemd-lock-handler.enable).

## Backward Incompatibilities {#sec-release-24.05-incompatibilities}
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Expand Up @@ -656,6 +656,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
70 changes: 70 additions & 0 deletions nixos/modules/services/misc/autobrr.nix
@@ -0,0 +1,70 @@
{ config, pkgs, lib, ... }:

with lib;

let
cfg = config.services.autobrr;
in
{
options = {
services.autobrr = {
enable = mkEnableOption (lib.mdDoc "Autobrr");

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

configureNginx = lib.mkOption {
type = lib.types.bool;
default = true;
description = lib.mdDoc "Configure nginx as a reverse proxy for Autobrr-web and the Go service.";
};

package = mkPackageOption pkgs "autobrr" { };
};
};

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

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

services.nginx = lib.mkIf cfg.configureNginx {
enable = true;
virtualHosts."localhost" = {
serverName = "localhost";
listen = [
{ addr = "0.0.0.0"; port = 7575; }
];

# Compiled NPM package
locations."/" = {
root = "${pkgs.autobrr}/autobrr-web";
index = "index.html";
};

# Go service
locations."/api" = {
proxyPass = "http://127.0.0.1:7474";
};
};
};

networking.firewall = mkIf cfg.openFirewall {
allowedTCPPorts = [ 7575 ];
};
};
}
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Expand Up @@ -134,6 +134,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 = handleTest ./ayatana-indicators.nix {};
Expand Down
16 changes: 16 additions & 0 deletions nixos/tests/autobrr.nix
@@ -0,0 +1,16 @@
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 f8fbc72

Please sign in to comment.