Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autobrr: init at 1.57.0 #287593

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2333,6 +2333,12 @@
githubId = 59499799;
keys = [ { fingerprint = "A0FF 4F26 6B80 0B86 726D EA5B 3C23 C7BD 9945 2036"; } ];
};
av-gal = {
email = "[email protected]";
github = "av-gal";
githubId = 32237198;
name = "Alex Galvin";
};
avh4 = {
email = "[email protected]";
github = "avh4";
Expand Down
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 @@ -77,6 +77,8 @@

- [Whoogle Search](https://github.com/benbusby/whoogle-search), a self-hosted, ad-free, privacy-respecting metasearch engine. Available as [services.whoogle-search](options.html#opt-services.whoogle-search.enable).

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

- [agorakit](https://github.com/agorakit/agorakit), an organization tool for citizens' collectives. Available with [services.agorakit](options.html#opt-services.agorakit.enable).

- [vivid](https://github.com/sharkdp/vivid), a generator for LS_COLOR. Available as [programs.vivid](#opt-programs.vivid.enable).
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 @@ -747,6 +747,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
85 changes: 85 additions & 0 deletions nixos/modules/services/misc/autobrr.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
config,
pkgs,
lib,
...
}:

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 $(cat ${cfg.secretFile}) -o %S/autobrr/config.toml 'sessionSecret'";
in
{
options = {
services.autobrr = {
enable = lib.mkEnableOption "Autobrr";

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

secretFile = lib.mkOption {
type = lib.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 <https://autobrr.com/configuration/autobrr>
for a full list.
'';
};

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

config = lib.mkIf cfg.enable {
assertions = [
{
assertion = !(cfg.settings ? sessionSecret);
message = ''
Session secrets should not be passed via settings, as
these are stored in the world-readable nix store.

Use the secretFile option instead.'';
}
];

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";
ExecStartPre = "${lib.getExe pkgs.bash} -c '${templaterCmd}'";
ExecStart = "${lib.getExe pkgs.autobrr} --config %S/autobrr";
Restart = "on-failure";
};
};

networking.firewall = lib.mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.settings.port ]; };
};
}
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ in {
auth-mysql = handleTest ./auth-mysql.nix {};
authelia = handleTest ./authelia.nix {};
auto-cpufreq = handleTest ./auto-cpufreq.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
25 changes: 25 additions & 0 deletions nixos/tests/autobrr.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import ./make-test-python.nix (
{ lib, ... }:

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

nodes.machine =
{ pkgs, ... }:
{
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";
};
};

testScript = ''
machine.wait_for_unit("autobrr.service")
machine.wait_for_open_port(7474)
machine.succeed("curl --fail http://localhost:7474/")
'';
}
)
96 changes: 96 additions & 0 deletions pkgs/by-name/au/autobrr/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
lib,
buildGoModule,
fetchFromGitHub,
stdenvNoCC,
nix-update-script,
nodejs,
pnpm_9,
typescript,
versionCheckHook,
}:

let
pname = "autobrr";
version = "1.57.0";
src = fetchFromGitHub {
owner = "autobrr";
repo = "autobrr";
tag = "v${version}";
hash = "sha256-RVkeSrL3ZfEz+oCICi8JFJ6AaOBBumi5mnnQYE5Gjt8=";
};

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-mABHRuZfjq9qNanfGGv+xDhs3bSufaWRecJypic8SWo=";
};

postBuild = ''
pnpm run build
'';

installPhase = ''
cp -r dist $out
'';
};
in
buildGoModule rec {
inherit
autobrr-web
pname
version
src
;

vendorHash = "sha256-rCtUE2/IwR6AnXQNgeH0TQ0BL7g6vi9L128xP0PwOXc=";

preBuild = ''
cp -r ${autobrr-web}/* web/dist
'';

ldflags = [
"-X main.version=${version}"
"-X main.commit=${src.tag}"
];

doInstallCheck = true;
nativeInstallCheckInputs = [
versionCheckHook
];
versionCheckProgram = "${placeholder "out"}/bin/autobrrctl";
versionCheckProgramArg = "version";

passthru.updateScript = nix-update-script {
av-gal marked this conversation as resolved.
Show resolved Hide resolved
extraArgs = [
"--subpackage"
"autobrr-web"
];
};

meta = {
description = "Modern, easy to use download automation for torrents and usenet";
license = lib.licenses.gpl2Plus;
homepage = "https://autobrr.com/";
changelog = "https://autobrr.com/release-notes/v${version}";
maintainers = with lib.maintainers; [ av-gal ];
mainProgram = "autobrr";
platforms = with lib.platforms; darwin ++ freebsd ++ linux;
};
av-gal marked this conversation as resolved.
Show resolved Hide resolved
}