From de39309ecf12ef6062a876dbfbbf9c5145efd4a5 Mon Sep 17 00:00:00 2001 From: rasmus-kirk Date: Fri, 1 Mar 2024 22:49:56 +0100 Subject: [PATCH] Fixed prowlarr/cross-seed groups --- nixarr/prowlarr/default.nix | 2 - nixarr/prowlarr/prowlarr-module/default.nix | 4 +- nixarr/transmission/cross-seed/default.nix | 23 +++--- nixarr/transmission/default.nix | 18 +++-- pkgs/cross-seed/default.nix | 83 ++++----------------- 5 files changed, 41 insertions(+), 89 deletions(-) diff --git a/nixarr/prowlarr/default.nix b/nixarr/prowlarr/default.nix index 7d9bd70..bf7716b 100644 --- a/nixarr/prowlarr/default.nix +++ b/nixarr/prowlarr/default.nix @@ -48,8 +48,6 @@ in { "d '${cfg.stateDir}' 0700 prowlarr root - -" ]; - users.groups.prowlarr = {}; - util-nixarr.services.prowlarr = { enable = true; dataDir = cfg.stateDir; diff --git a/nixarr/prowlarr/prowlarr-module/default.nix b/nixarr/prowlarr/prowlarr-module/default.nix index 7655ff4..48c919f 100644 --- a/nixarr/prowlarr/prowlarr-module/default.nix +++ b/nixarr/prowlarr/prowlarr-module/default.nix @@ -70,6 +70,8 @@ in { }; }; - users.groups = mkIf (cfg.group == "prowlarr") {}; + users.groups = mkIf (cfg.group == "prowlarr") { + prowlarr = { }; + }; }; } diff --git a/nixarr/transmission/cross-seed/default.nix b/nixarr/transmission/cross-seed/default.nix index b5278e0..3cd99a5 100644 --- a/nixarr/transmission/cross-seed/default.nix +++ b/nixarr/transmission/cross-seed/default.nix @@ -6,9 +6,9 @@ }: with lib; let cfg = config.util-nixarr.services.cross-seed; - settingsFormat = pkgs.formats.json {}; - settingsFile = settingsFormat.generate "settings.json" cfg.settings; - cross-seedPkg = import ../../../pkgs/cross-seed { inherit (pkgs) stdenv lib fetchFromGitHub; }; + #settingsFormat = pkgs.formats.json {}; + #settingsFile = settingsFormat.generate "settings.json" cfg.settings; + cross-seedPkg = pkgs.callPackage ../../../pkgs/cross-seed {}; in { options = { util-nixarr.services.cross-seed = { @@ -65,15 +65,16 @@ in { serviceConfig = { # Run as root in case that the cfg.credentialsFile is not readable by cross-seed - ExecStartPre = [("+" + pkgs.writeShellScript "transmission-prestart" '' - ${pkgs.jq}/bin/jq --slurp add ${settingsFile} '${cfg.credentialsFile}' | - install -D -m 600 -o '${cfg.user}' /dev/stdin '${cfg.dataDir}/config.json' - '' - )]; + #ExecStartPre = [("+" + pkgs.writeShellScript "transmission-prestart" '' + # ${pkgs.jq}/bin/jq --slurp add ${settingsFile} '${cfg.credentialsFile}' | + # install -D -m 600 -o '${cfg.user}' /dev/stdin '${cfg.dataDir}/config.json' + #'' + #)]; Type = "simple"; User = cfg.user; Group = cfg.group; - ExecStart = "${getExe cross-seedPkg} daemon"; + ExecStart = "${cross-seedPkg}/bin/cross-seed daemon"; + #ExecStart = "${pkgs.cowsay}/bin/cowsay"; Restart = "on-failure"; }; }; @@ -85,6 +86,8 @@ in { }; }; - users.groups = mkIf (cfg.group == "cross-seed") {}; + users.groups = mkIf (cfg.group == "cross-seed") { + cross-seed = { }; + }; }; } diff --git a/nixarr/transmission/default.nix b/nixarr/transmission/default.nix index 367bba9..62ab203 100644 --- a/nixarr/transmission/default.nix +++ b/nixarr/transmission/default.nix @@ -9,7 +9,7 @@ with lib; let nixarr = config.nixarr; cfg-cross-seed = config.nixarr.transmission.privateTrackers.cross-seed; transmissionCrossSeedScript = with builtins; pkgs.writeShellApplication { - name = "mk-cross-seed-credentials"; + name = "transmission-cross-seed-script"; runtimeInputs = with pkgs; [ curl ]; @@ -223,11 +223,11 @@ in { } // cfg-cross-seed.extraSettings; }; # Run as root in case that the cfg.credentialsFile is not readable by cross-seed - systemd.services.cross-seed.serviceConfig = mkIf cfg-cross-seed.enable { - ExecStartPre = [(mkBefore - ("+" + (getExe mkCrossSeedCredentials)) - )]; - }; + #systemd.services.cross-seed.serviceConfig = mkIf cfg-cross-seed.enable { + # ExecStartPre = [(mkBefore + # ("+" + (getExe mkCrossSeedCredentials)) + # )]; + #}; services.transmission = { enable = true; @@ -269,8 +269,10 @@ in { anti-brute-force-enabled = true; anti-brute-force-threshold = 10; - script-torrent-done-enabled = cfg-cross-seed.enable; - script-torrent-done-filename = if cfg-cross-seed.enable then transmissionCrossSeedScript else null; + #script-torrent-done-enabled = cfg-cross-seed.enable; + #script-torrent-done-filename = if cfg-cross-seed.enable then + # "${transmissionCrossSeedScript}/bin/transmission-cross-seed-script" + #else null; message-level = if cfg.messageLevel == "none" diff --git a/pkgs/cross-seed/default.nix b/pkgs/cross-seed/default.nix index b39f28a..2a69754 100644 --- a/pkgs/cross-seed/default.nix +++ b/pkgs/cross-seed/default.nix @@ -1,75 +1,22 @@ -{ - config, - pkgs, - lib, - ... -}: -with lib; let - cfg = config.util-nixarr.services.prowlarr; - settingsFormat = pkgs.formats.json {}; - settingsFile = settingsFormat.generate "settings.json" cfg.settings; - cross-seedPkg = import ../../../pkgs/cross-seed { inherit (pkgs) stdenv lib fetchFromGitHub; }; -in { - options = { - util-nixarr.services.prowlarr = { - enable = mkEnableOption "cross-seed"; +{ lib, buildNpmPackage, fetchFromGitHub }: - configFile = mkOption { - type = with types; nullOr path; - default = null; - example = "/var/lib/secrets/cross-seed/settings.json"; - description = ""; - }; +buildNpmPackage rec { + pname = "cross-seed"; + version = "5.9.2"; - dataDir = mkOption { - type = types.path; - default = "/var/lib/cross-seed"; - }; - - user = mkOption { - type = types.str; - default = "cross-seed"; - description = "User account under which cross-seed runs."; - }; - - group = mkOption { - type = types.str; - default = "cross-seed"; - description = "Group under which cross-seed runs."; - }; - }; + src = fetchFromGitHub { + owner = "cross-seed"; + repo = pname; + rev = "v${version}"; + hash = "sha256-E0AlsFV9RP01YVwjw6ZQ8Lf1IVyuudxrb5oJ61EfIyo="; }; - config = mkIf cfg.enable { - systemd.tmpfiles.rules = [ - "d '${cfg.dataDir}' 0700 ${cfg.user} ${cfg.group} - -" - ]; - - systemd.services.prowlarr = { - description = "cross-seed"; - after = ["network.target"]; - wantedBy = ["multi-user.target"]; - - environment.CONFIG_DIR = cfg.dataDir; - - serviceConfig = { - ExecStartPre = [("+" + pkgs.writeShellScript "transmission-prestart" '' - mv ${cfg.configFile} ${cfg.dataDir} - '')]; - Type = "simple"; - User = cfg.user; - Group = cfg.group; - ExecStart = "${getExe cross-seedPkg} daemon"; - Restart = "on-failure"; - }; - }; - - users.users = mkIf (cfg.user == "cross-seed") { - cross-seed = { - group = cfg.group; - }; - }; + npmDepsHash = "sha256-hZKLv+bzRFiMjNemydCUC1d7xul7Mm+vOPtCUD7p9XQ="; - users.groups = mkIf (cfg.group == "cross-seed") {}; + meta = with lib; { + description = "cross-seed is an app designed to help you download torrents that you can cross seed based on your existing torrents"; + homepage = "https://www.cross-seed.org"; + license = licenses.asl20; + maintainers = with maintainers; [ rasmus-kirk ]; }; }