From 70f1135cbc3dc62abe6bac32f9b9cf4da456318f Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Wed, 29 Dec 2021 20:37:49 +0100 Subject: [PATCH] transmission works like it should --- nixos/configs/robi/syncthing.nix | 9 ++- nixos/configs/robi/transmission.nix | 96 +++++++---------------------- nixos/system/all/syncthing.nix | 2 +- 3 files changed, 26 insertions(+), 81 deletions(-) diff --git a/nixos/configs/robi/syncthing.nix b/nixos/configs/robi/syncthing.nix index 599eac5..eef3104 100644 --- a/nixos/configs/robi/syncthing.nix +++ b/nixos/configs/robi/syncthing.nix @@ -81,16 +81,15 @@ enable = true; path = "/media/syncthing/series"; }; + music-library = { + enable = true; + path = "/media/syncthing/music"; + }; # todo : no need to place it on encrypted drive #music-projects = { # enable = true; # path = "/home/syncthing/music-projects"; #}; - #music-library = { - # enable = true; - # path = "/media/syncthing/music-library"; - # rescanInterval = 8 * 3600; - #}; #smartphone-folder = { # enable = true; # path = "/media/syncthing/smartphone-folder"; diff --git a/nixos/configs/robi/transmission.nix b/nixos/configs/robi/transmission.nix index 5fa9e3f..970e206 100644 --- a/nixos/configs/robi/transmission.nix +++ b/nixos/configs/robi/transmission.nix @@ -33,53 +33,29 @@ let # TR_TORRENT_NAME # # # ############################################# - completionScript = let - copy_map = { - "/media/torrent/downloads/movies" = "/media/syncthing/movies/incoming"; - "/media/torrent/downloads" = "/media/torrent/incoming"; - }; - copy_script = lib.concatStringsSep "\n" (lib.mapAttrsToList (source: target: '' - if [[ "$TR_TORRENT_DIR" == "${source}" ]] - then - cp -val "$TR_TORRENT_DIR/$TR_TORRENT_NAME" "${target}/$TR_TORRENT_NAME" - fi - '') copy_map); - in - pkgs.writers.writeBash "torrent-finished" '' - - ${copy_script} - - ${pkgs.jq}/bin/jq '{ - "token": "'"$PUSHOVER_API_KEY"'", - "user": "'"$PUSHOVER_USER_KEY"'", - "titel": "transmission", - "message": "'"$TR_TORRENT_NAME finished"'" - }' >> /media/torrent/finish.log - - ${pkgs.jq}/bin/jq '{ - "token": "'"$PUSHOVER_API_KEY"'", - "user": "'"$PUSHOVER_USER_KEY"'", - "titel": "transmission", - "message": "'"$TR_TORRENT_NAME finished"'" - }' \ - | ${pkgs.curl}/bin/curl \ - -sS \ - -X POST \ - -H 'Content-Type: application/json' \ - -d @- \ - https://api.pushover.net/1/messages.json - ''; - + completionScript = + let + copy_map = { + "/media/torrent/downloads/series" = "/media/syncthing/series/incoming"; + "/media/torrent/downloads/music" = "/media/syncthing/music/incoming"; + "/media/torrent/downloads/movies" = "/media/syncthing/movies/incoming"; + "/media/torrent/downloads" = "/media/torrent/incoming"; + }; + copy_script = lib.concatStringsSep "\n" (lib.mapAttrsToList + (source: target: '' + if [[ "$TR_TORRENT_DIR" == "${source}" ]] + then + cp -val "$TR_TORRENT_DIR/$TR_TORRENT_NAME" "${target}/$TR_TORRENT_NAME" + fi + '') + copy_map); + in + pkgs.writers.writeBash "torrent-finished" copy_script; in { - #users.users.transmission = { - # isSystemUser = true; - # uid = config.ids.uids.transmission; - #}; - sops.secrets.nordvpn = { }; - sops.secrets.transmissionPushover= { }; + sops.secrets.transmissionPushover = { }; containers.torrent = { @@ -124,42 +100,12 @@ in config = { config, pkgs, lib, ... }: { - #services.journalbeat = { - # enable = true; - # extraConfig = '' - # journalbeat.inputs: - # - paths: [] - # # Position to start reading from journal. Valid values: head, tail, cursor - # seek: cursor - # # Fallback position if no cursor data is available. - # cursor_seek_fallback: tail - # output.logstash: - # # Boolean flag to enable or disable the output module. - # enabled: true - # # Graylog host and the beats input - # hosts: ["${hostAddress}:5044"] - # # If enabled only a subset of events in a batch of events is transferred per - # # transaction. The number of events to be sent increases up to `bulk_max_size` - # # if no error is encountered. - # slow_start: true - # # The number of seconds to wait before trying to reconnect to Graylog - # # after a network error. After waiting backoff.init seconds, the Beat - # # tries to reconnect. If the attempt fails, the backoff timer is increased - # # exponentially up to backoff.max. After a successful connection, the backoff - # # timer is reset. The default is 1s. - # backoff.init: 1s - # # The maximum number of seconds to wait before attempting to connect to - # # Graylog after a network error. The default is 60s. - # backoff.max: 60s - # ''; - #}; - services.journald.extraConfig = "SystemMaxUse=1G"; # allow transmission to write in syncthing folders users.groups.syncthing = { gid = config.ids.gids.syncthing; - members = ["transmission"]; + members = [ "transmission" ]; }; services.transmission = { @@ -233,7 +179,7 @@ in "/run/secrets/transmissionPushover" ]; BindPaths = lib.mkForce [ - "/media" + "/media" # this is needed otherwise cp -l is not working "/var/lib/transmission/.config/transmission-daemon" ]; }; diff --git a/nixos/system/all/syncthing.nix b/nixos/system/all/syncthing.nix index 09aa020..9a1faa1 100644 --- a/nixos/system/all/syncthing.nix +++ b/nixos/system/all/syncthing.nix @@ -156,7 +156,7 @@ with lib; { enable = lib.mkDefault false; id = "gytmq-r2zrx"; watch = false; - devices = [ "porani" "workout" "workhorse" "pepe" "sterni" ]; + devices = [ "workhorse" "pepe" "sterni" "robi" ]; versioning = { type = "simple"; params.keep = "10";