feat: add nixarr
This commit is contained in:
parent
e6cae70857
commit
974b872e83
42 changed files with 1161 additions and 4 deletions
73
machines/moritz-server/nixarr/autobrr.nix
Normal file
73
machines/moritz-server/nixarr/autobrr.nix
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
cfg = config.nixarr.autobrr;
|
||||
|
||||
createAdminUser = pkgs.writeShellApplication {
|
||||
name = "create-admin-user";
|
||||
runtimeInputs = [config.nixarr.autobrr.package];
|
||||
text = ''
|
||||
file="${cfg.stateDir}/admin-created"
|
||||
if [ ! -f $file ]; then
|
||||
autobrrctl --config "${cfg.stateDir}" create-user admin < "${config.clan.core.vars.generators.nixarr-autobrr.files.password.path}"
|
||||
touch "$file"
|
||||
fi
|
||||
'';
|
||||
};
|
||||
in {
|
||||
clan.core.vars.generators."nixarr-autobrr" = {
|
||||
prompts.password = {
|
||||
type = "hidden";
|
||||
persist = true;
|
||||
description = "Leave empty to generate automatically";
|
||||
};
|
||||
|
||||
files.password = {};
|
||||
|
||||
runtimeInputs = [
|
||||
pkgs.coreutils
|
||||
pkgs.xkcdpass
|
||||
];
|
||||
|
||||
script = ''
|
||||
prompt_value="$(cat "$prompts/password")"
|
||||
if [[ -n "''${prompt_value-}" ]]; then
|
||||
echo "$prompt_value" | tr -d "\n" > "$out"/password
|
||||
else
|
||||
xkcdpass --numwords 4 --delimiter - --count 1 | tr -d "\n" > "$out"/password
|
||||
fi
|
||||
'';
|
||||
};
|
||||
systemd.services.autobrr-setup = {
|
||||
description = "Setup autobrr user";
|
||||
wantedBy = ["default.target"];
|
||||
requires = ["autobrr.service"];
|
||||
after = ["autobrr.service"];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecStart = lib.getExe createAdminUser;
|
||||
};
|
||||
};
|
||||
|
||||
nixarr.autobrr = {
|
||||
enable = true;
|
||||
vpn.enable = true;
|
||||
settings = {
|
||||
checkForUpdates = false;
|
||||
port = 7474;
|
||||
host = lib.mkForce "192.168.15.1";
|
||||
logLevel = "INFO";
|
||||
};
|
||||
};
|
||||
services.nginx.virtualHosts."autobrr.moritz.place" = {
|
||||
forceSSL = true;
|
||||
useACMEHost = "any.moritz.place";
|
||||
locations."/" = {
|
||||
proxyPass = "http://192.168.15.1:${builtins.toString config.nixarr.autobrr.settings.port}";
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue