diff --git a/nix/home/programs/flood/default.nix b/nix/home/programs/flood/default.nix index 9f0dafc..35216e3 100644 --- a/nix/home/programs/flood/default.nix +++ b/nix/home/programs/flood/default.nix @@ -33,17 +33,5 @@ wantedBy = [ "multi-user.target" ]; after = [ "network.target" ]; }; - -# rtorrent = { -# enable = true; -# serviceConfig = { -# User = "flood"; -# Type = "forking"; -# ExecStart = "${pkgs.rtorrent}/bin/rtorrent"; -# Restart = "on-failure"; -# }; -# wantedBy = [ "multi-user.target" ]; -# after = [ "network.target" ]; -# }; }; } diff --git a/nix/home/programs/rtorrent/default.nix b/nix/home/programs/rtorrent/default.nix new file mode 100644 index 0000000..f36777d --- /dev/null +++ b/nix/home/programs/rtorrent/default.nix @@ -0,0 +1,16 @@ +{ pkgs, finalDir, downloadDir, watchDir }: +{ + + services.rtorrent = { + enable = true; + downloadDir = downloadDir; + group = "users"; + configText = + builtins.readFile (pkgs.substituteAll { + src = ./rtorrent.rc; + watchDir = watchDir; + finalDir = finalDir; + }); + }; + +} diff --git a/nix/home/programs/rtorrent/rtorrent.rc b/nix/home/programs/rtorrent/rtorrent.rc new file mode 100644 index 0000000..9eb2193 --- /dev/null +++ b/nix/home/programs/rtorrent/rtorrent.rc @@ -0,0 +1,41 @@ +# Enable the default ratio group. +ratio.enable= + +# Change the limits, the defaults should be sufficient. +ratio.min.set = 100 +ratio.max.set = 300 +ratio.upload.set = 20M + +# Changing the command triggered when the ratio is reached. +# (the default is "d.try_close= ; d.ignore_commands.set=1") +method.set = group.seeding.ratio.command, "d.close= ; d.erase=" + +# Add new method to get finished dir (called get_finished_dir) +method.insert = d.get_finished_dir,simple,"cat=@finalDir@/,$d.custom1=" + +# Bind event "torrent has finished" to action "move to new directory based on label" +# method.set_key = event.download.finished,move_complete +# Modifies the event.download.finished event to also have a new “key” +# called “move_complete”. From what I understand, rTorrent executes all +# “keys” in an event whenever that event is fired. The +# event.download.finished event fires whenever a torrent has finished +# downloading. The stuff within the quotation marks is the new key’s +# commands. Each command is separated by a semicolon (;). +# d.directory.set=$d.get_finished_dir=; +# d.directory.set sets the directory of the torrent in rTorrent’s own +# information. It does not move the torrent, just means rTorrent will +# look in that directory from now on. $d.get_finished_dir just runs the +# get_finished_dir method preciously inserted; constructing a path name +# by combining [folder]/finished/ with whatever label was applied +# ($d.custom1 contains the label). +# execute=mkdir,-p,$d.get_finished_dir=; +# Gets the same path name and makes sure the directory actually exists. +# Mkdir is the standard *nix command for creating directories. -p means +# creating parent directories if needed and not complaining if directory +# already exists. +# execute=mv,-u,$d.base_path=,$d.get_finished_dir= +# Uses the same “execute” functionality as above to run the standard *nix +# mv command to move the torrent’s files (whose location is stored in +# d.base_path) to, once again, the directory whose name was constructed +# by the get_finished_dir method. +method.set_key = event.download.finished,move_complete,"d.directory.set=$d.get_finished_dir=;execute=mkdir,-p,$d.get_finished_dir=;execute=mv,-u,$d.base_path=,$d.get_finished_dir=" diff --git a/nix/system/framework/hardware-configuration.nix b/nix/system/framework/hardware-configuration.nix index 6b718b2..bb4867d 100644 --- a/nix/system/framework/hardware-configuration.nix +++ b/nix/system/framework/hardware-configuration.nix @@ -26,11 +26,6 @@ fsType = "vfat"; }; - fileSystems."/storage" = { - device = "192.168.1.168:/storage"; - fsType = "nfs"; - }; - swapDevices = [{ device = "/dev/disk/by-uuid/97c769a2-55da-475a-8dc0-d74d8bbde514"; }]; diff --git a/nix/system/svalbard/configuration.nix b/nix/system/svalbard/configuration.nix index 28208cd..a143877 100644 --- a/nix/system/svalbard/configuration.nix +++ b/nix/system/svalbard/configuration.nix @@ -10,6 +10,12 @@ # Include the results of the hardware scan. ./hardware-configuration.nix ../common/users.nix + (import ../../home/programs/rtorrent { + pkgs = pkgs; + downloadDir = "/storage/temp"; + finalDir = "/storage"; + watchDir = "/storage/torrents"; + }) ]; # Bootloader.