Skip to content

Commit

Permalink
Fixed prowlarr/cross-seed groups
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmus-kirk committed Mar 1, 2024
1 parent d396bd3 commit 10a605e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 81 deletions.
2 changes: 0 additions & 2 deletions nixarr/prowlarr/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ in {
"d '${cfg.stateDir}' 0700 prowlarr root - -"
];

users.groups.prowlarr = {};

util-nixarr.services.prowlarr = {
enable = true;
dataDir = cfg.stateDir;
Expand Down
4 changes: 3 additions & 1 deletion nixarr/prowlarr/prowlarr-module/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ in {
};
};

users.groups = mkIf (cfg.group == "prowlarr") {};
users.groups = mkIf (cfg.group == "prowlarr") {
prowlarr = { };
};
};
}
8 changes: 5 additions & 3 deletions nixarr/transmission/cross-seed/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ 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; };
cross-seedPkg = pkgs.callPackage ../../../pkgs/cross-seed {};
in {
options = {
util-nixarr.services.cross-seed = {
Expand Down Expand Up @@ -73,7 +73,7 @@ in {
Type = "simple";
User = cfg.user;
Group = cfg.group;
ExecStart = "${getExe cross-seedPkg} daemon";
ExecStart = "${cross-seedPkg}/bin/cross-seed daemon";
Restart = "on-failure";
};
};
Expand All @@ -85,6 +85,8 @@ in {
};
};

users.groups = mkIf (cfg.group == "cross-seed") {};
users.groups = mkIf (cfg.group == "cross-seed") {
cross-seed = { };
};
};
}
16 changes: 9 additions & 7 deletions nixarr/transmission/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];

Expand All @@ -24,13 +24,13 @@ with lib; let

text =
"INDEX_LINKS=("
+ strings.concatMapStringsSep " " toString cfg.privateTrackers.cross-seed.indexIds
+ (strings.concatMapStringsSep " " toString cfg.privateTrackers.cross-seed.indexIds)
+ ")"
''
+ ''
TMP_JSON=$(mktemp)
CRED_FILE="/run/secrets/cross-seed/credentialsFile.json"
PROWLARR_API_KEY=$(xq '.Config.ApiKey' "${nixarr.prowlarr.stateDir}/config.xml")
CRED_DIR=$(dirname "$filePath")
CRED_DIR=$(dirname "$CRED_FILE")
echo '{}' > "$CRED_FILE"
chmod 400 "$CRED_FILE"
Expand Down Expand Up @@ -224,8 +224,8 @@ in {
};
# 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))
ExecStartPre = mkBefore [(
"+" + "${mkCrossSeedCredentials}/bin/mk-cross-seed-credentials"
)];
};

Expand Down Expand Up @@ -270,7 +270,9 @@ in {
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-filename = if cfg-cross-seed.enable then
"${transmissionCrossSeedScript}/bin/transmission-cross-seed-script"
else null;

message-level =
if cfg.messageLevel == "none"
Expand Down
83 changes: 15 additions & 68 deletions pkgs/cross-seed/default.nix
Original file line number Diff line number Diff line change
@@ -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 ];
};
}

0 comments on commit 10a605e

Please sign in to comment.