-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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.51.0 #287593
Draft
av-gal
wants to merge
3
commits into
NixOS:master
Choose a base branch
from
av-gal:autobrr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+189
−0
Draft
autobrr: init at 1.51.0 #287593
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2246,6 +2246,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"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://autobrr.com/configuration/autobrr> | ||
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 ]; }; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/") | ||
''; | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
}; | ||
av-gal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider
inherits
where you find yourself usinglib.*
excessively.this nix.dev page on best practices with
with
may be helpfulan issue (#208242) has been made to track inappropriate uses of
with
such as this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just prefix the used library function with
lib.
.