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