-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
90 additions
and
0 deletions.
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
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,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 ]; | ||
}; | ||
}; | ||
} |
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,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/") | ||
''; | ||
}) |