Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hosts/glyph/services/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
];
users.groups.media = {};
users.users.mu.extraGroups = ["media"];
users.users.${config.services.transmission.user}.extraGroups = ["media"];

services.cockpit.enable = true;
services.openssh.enable = true;
Expand Down
8 changes: 7 additions & 1 deletion hosts/glyph/services/samba.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
// shares;
};

# Ensure Unsorted is group-writable with setgid so Samba (force user jellyfin)
# can write and new files inherit the media group
systemd.tmpfiles.rules = [
"d /mnt/media/Unsorted 2775 ${config.services.jellyfin.user} ${config.services.jellyfin.group} -"
];

systemd.services.ensureSambaPermissions = {
description = "Ensures correct permissions within Samba shares";
serviceConfig = {
Expand All @@ -64,7 +70,7 @@
"${pkgs.coreutils}/bin/chown -R ${defaultUsrGrp} archive"
"${pkgs.coreutils}/bin/chown -R ${defaultUsrGrp} backup"
# N.B.: /mnt/media/Music is used by Roon, not Jellyfin
"${pkgs.coreutils}/bin/chown -R ${jellyfinUsrGrp} media/Movies media/TV media/Video"
"${pkgs.coreutils}/bin/chown -R ${jellyfinUsrGrp} media/Movies media/TV media/Unsorted media/Video"
"${pkgs.coreutils}/bin/chown -R ${defaultUsrGrp} media/Music"
"${pkgs.coreutils}/bin/chown -R ${transmissionUsrGrp} torrents"
"${pkgs.coreutils}/bin/chown -R ${defaultUsrGrp} unsorted"
Expand Down
20 changes: 19 additions & 1 deletion hosts/glyph/services/torrents.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@
--form-string "url=https://torrents.zx.dev" \
--form-string "url_title=View torrents" \
https://api.pushover.net/1/messages.json

# Copy .mkv files to Unsorted for Jellyfin
UNSORTED="/mnt/media/Unsorted"
TORRENT_PATH="$TR_TORRENT_DIR/$TR_TORRENT_NAME"

if [ -d "$TORRENT_PATH" ]; then
# Folder torrent: copy the folder if it contains at least one .mkv
if find "$TORRENT_PATH" -name '*.mkv' -print -quit | grep -q .; then
cp -r "$TORRENT_PATH" "$UNSORTED/"
chgrp -R media "$UNSORTED/$TR_TORRENT_NAME"
chmod -R g+rw "$UNSORTED/$TR_TORRENT_NAME"
fi
elif [[ "$TR_TORRENT_NAME" == *.mkv ]]; then
# Single .mkv file
cp "$TORRENT_PATH" "$UNSORTED/"
chgrp media "$UNSORTED/$TR_TORRENT_NAME"
chmod g+rw "$UNSORTED/$TR_TORRENT_NAME"
fi
'';
cache-size-mb = 256;
download-queue-enabled = true;
Expand All @@ -62,7 +80,7 @@
webHome = pkgs.transmissionic;
};

systemd.services.transmission.path = [pkgs.curl];
systemd.services.transmission.path = [pkgs.curl pkgs.findutils];

networking.firewall.allowedTCPPorts = [config.services.transmission.settings.peer-port];
}
Loading