Update services/sabnzbd.nix

This commit is contained in:
rope 2026-05-04 02:29:10 -07:00
parent e77ca8fceb
commit dda93320d8

View file

@ -3,10 +3,12 @@ let
patchConfig = pkgs.writeShellScript "sabnzbd-patch-config" '' patchConfig = pkgs.writeShellScript "sabnzbd-patch-config" ''
CONFIG=/var/lib/sabnzbd/sabnzbd.ini CONFIG=/var/lib/sabnzbd/sabnzbd.ini
HOSTNAME=sabnzbd.nordhammer.it HOSTNAME=sabnzbd.nordhammer.it
if [ ! -f "$CONFIG" ]; then if [ ! -f "$CONFIG" ]; then
printf '[misc]\nhost_whitelist = %s\nport = 8085\n' "$HOSTNAME" > "$CONFIG" printf '[misc]\nhost_whitelist = %s\nport = 8085\n' "$HOSTNAME" > "$CONFIG"
exit 0 exit 0
fi fi
${pkgs.python3}/bin/python3 - <<'EOF' ${pkgs.python3}/bin/python3 - <<'EOF'
import configparser, os, sys import configparser, os, sys
config_file = '/var/lib/sabnzbd/sabnzbd.ini' config_file = '/var/lib/sabnzbd/sabnzbd.ini'
@ -27,10 +29,12 @@ EOF
in in
{ {
config = lib.mkIf (config.networking.hostName == "FredOS-Mediaserver") { config = lib.mkIf (config.networking.hostName == "FredOS-Mediaserver") {
users.users.sabnzbd = { users.users.sabnzbd = {
isSystemUser = true; isSystemUser = true;
group = "media"; group = "media";
}; };
systemd.tmpfiles.rules = [ systemd.tmpfiles.rules = [
"d /var/lib/sabnzbd 0755 sabnzbd media -" "d /var/lib/sabnzbd 0755 sabnzbd media -"
"Z /var/lib/sabnzbd 0755 sabnzbd media -" "Z /var/lib/sabnzbd 0755 sabnzbd media -"
@ -39,6 +43,7 @@ in
"d /mnt/storage/usenet/incomplete 2775 sabnzbd media -" "d /mnt/storage/usenet/incomplete 2775 sabnzbd media -"
"Z /mnt/storage/usenet/incomplete 2775 sabnzbd media -" "Z /mnt/storage/usenet/incomplete 2775 sabnzbd media -"
]; ];
systemd.services.sabnzbd = { systemd.services.sabnzbd = {
description = "SABnzbd usenet downloader"; description = "SABnzbd usenet downloader";
after = [ "network.target" ]; after = [ "network.target" ];