From 37b9135e371bf92f6c18c8ff1bdffd2ceab48e41 Mon Sep 17 00:00:00 2001 From: Alex Galvin Date: Fri, 9 Feb 2024 17:39:24 -0500 Subject: [PATCH 1/3] maintainers: add av-gal --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index f064772cf3a66..cb7db41fb3d0f 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -2246,6 +2246,12 @@ githubId = 59499799; keys = [ { fingerprint = "A0FF 4F26 6B80 0B86 726D EA5B 3C23 C7BD 9945 2036"; } ]; }; + av-gal = { + email = "alex.v.galvin@gmail.com"; + github = "av-gal"; + githubId = 32237198; + name = "Alex Galvin"; + }; avh4 = { email = "gruen0aermel@gmail.com"; github = "avh4"; From 4e759cd90eece523dcdacf1f50c9ca0d8b883091 Mon Sep 17 00:00:00 2001 From: Alex Galvin Date: Fri, 9 Feb 2024 17:51:04 -0500 Subject: [PATCH 2/3] autobrr: init at 1.51.1 --- pkgs/by-name/au/autobrr/package.nix | 83 +++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 pkgs/by-name/au/autobrr/package.nix diff --git a/pkgs/by-name/au/autobrr/package.nix b/pkgs/by-name/au/autobrr/package.nix new file mode 100644 index 0000000000000..1929260424d74 --- /dev/null +++ b/pkgs/by-name/au/autobrr/package.nix @@ -0,0 +1,83 @@ +{ + lib, + cacert, + buildGoModule, + fetchFromGitHub, + stdenvNoCC, + nix-update-script, + nodejs, + nodePackages, + pnpm_9, + typescript, +}: + +let + pname = "autobrr"; + version = "1.51.1"; + src = fetchFromGitHub { + owner = "autobrr"; + repo = "autobrr"; + rev = "v${version}"; + hash = "sha256-2lAIx9wyuZ/ILXX66UoDAw122xF35Ij/omT0ynvQFvg="; + }; + + autobrr-web = stdenvNoCC.mkDerivation { + pname = "${pname}-web"; + inherit src version; + + nativeBuildInputs = [ + nodejs + pnpm_9.configHook + typescript + ]; + + sourceRoot = "${src.name}/web"; + + pnpmDeps = pnpm_9.fetchDeps { + inherit (autobrr-web) + pname + version + src + sourceRoot + ; + hash = "sha256-TcfxE18nkOSxa4UG2euK1hViPw8tY0TS6tayGJsNNog="; + }; + + postBuild = '' + pnpm run build + ''; + + installPhase = '' + cp -r dist $out + ''; + }; +in +buildGoModule rec { + inherit + autobrr-web + pname + version + src + ; + + vendorHash = "sha256-kKyRDIgPsd4uFqIsVRJlxkcQab01xlnX/q349CPIafQ="; + + preBuild = '' + cp -r ${autobrr-web}/* web/dist + ''; + + ldflags = [ + "-X main.version=${version}" + "-X main.commit=${src.rev}" + ]; + + passthru.updateScript = nix-update-script { }; + + meta = with lib; { + description = "Modern, easy to use download automation for torrents and usenet"; + license = licenses.gpl2Plus; + homepage = "https://autobrr.com/"; + maintainers = with maintainers; [ av-gal ]; + mainProgram = "autobrr"; + }; +} From 2183f132ed0eaa751506458c1b892f033638a5bf Mon Sep 17 00:00:00 2001 From: Alex Galvin Date: Fri, 9 Feb 2024 17:55:06 -0500 Subject: [PATCH 3/3] nixos/autobrr: init --- .../manual/release-notes/rl-2505.section.md | 2 + nixos/modules/module-list.nix | 1 + nixos/modules/services/misc/autobrr.nix | 76 +++++++++++++++++++ nixos/tests/all-tests.nix | 1 + nixos/tests/autobrr.nix | 20 +++++ 5 files changed, 100 insertions(+) create mode 100644 nixos/modules/services/misc/autobrr.nix create mode 100644 nixos/tests/autobrr.nix diff --git a/nixos/doc/manual/release-notes/rl-2505.section.md b/nixos/doc/manual/release-notes/rl-2505.section.md index 347cbf0d61272..da23d44e2253a 100644 --- a/nixos/doc/manual/release-notes/rl-2505.section.md +++ b/nixos/doc/manual/release-notes/rl-2505.section.md @@ -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). - [agorakit](https://github.com/agorakit/agorakit), an organization tool for citizens' collectives. Available with [services.agorakit](#opt-services.agorakit.enable). diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 8551e1b3406c5..916da669a31e1 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -728,6 +728,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 diff --git a/nixos/modules/services/misc/autobrr.nix b/nixos/modules/services/misc/autobrr.nix new file mode 100644 index 0000000000000..fb243489c5249 --- /dev/null +++ b/nixos/modules/services/misc/autobrr.nix @@ -0,0 +1,76 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.services.autobrr; + configFormat = pkgs.formats.toml { }; + configTemplate = 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."; + }; + + secretFile = mkOption { + type = types.path; + description = + "File containing the session secret for the Autobrr web interface."; + }; + + settings = lib.mkOption { + type = lib.types.submodule { freeformType = configFormat.type; }; + default = { + host = "127.0.0.1"; + port = "7474"; + checkForUpdates = true; + }; + example = { logLevel = "DEBUG"; }; + description = '' + Autobrr configuration options. + + Refer to + for a full list. + ''; + }; + + package = mkPackageOption pkgs "autobrr" { }; + }; + }; + + config = mkIf cfg.enable { + assertions = [{ + assertion = cfg.settings.sessionSecret == null; + message = "Session secrets must be passed using the secretFile option."; + }]; + + 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"; + ExecPreStart = + "${lib.getExe pkgs.dasel} put -f '${configTemplate}' -v '${ + builtins.readFile cfg.secretFile + }' -o %S/config.toml 'sessionSecret'"; + ExecStart = "${lib.getExe pkgs.autobrr} --config %S/config.toml"; + Restart = "on-failure"; + }; + }; + + networking.firewall = + mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.settings.port ]; }; + }; +} diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 6f941cc254ad4..eede2fc66db51 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -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; diff --git a/nixos/tests/autobrr.nix b/nixos/tests/autobrr.nix new file mode 100644 index 0000000000000..4558fd1a781a5 --- /dev/null +++ b/nixos/tests/autobrr.nix @@ -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/") + ''; + } +)