From 0f74c957a1d44fc704585bf0280ee376a829e761 Mon Sep 17 00:00:00 2001 From: Haak Saxberg Date: Mon, 6 Nov 2023 20:52:58 -0800 Subject: [PATCH] qbitorrent has replaced flood and rtorrent --- nix/deployments/nixops.nix | 2 +- nix/home/programs/flood/default.nix | 39 ----------- nix/home/programs/qbittorrent/default.nix | 9 ++- nix/home/programs/rtorrent/default.nix | 38 ---------- nix/home/programs/rtorrent/rtorrent.rc | 85 ----------------------- nix/system/svalbard/configuration.nix | 7 -- 6 files changed, 9 insertions(+), 171 deletions(-) delete mode 100644 nix/home/programs/flood/default.nix delete mode 100644 nix/home/programs/rtorrent/default.nix delete mode 100644 nix/home/programs/rtorrent/rtorrent.rc diff --git a/nix/deployments/nixops.nix b/nix/deployments/nixops.nix index f0053f9..2ef5bdb 100644 --- a/nix/deployments/nixops.nix +++ b/nix/deployments/nixops.nix @@ -79,7 +79,7 @@ in deployment.targetHost = nasIp; imports = [ ../system/svalbard/configuration.nix - ../home/programs/flood + (import ../home/programs/qbittorrent { pkgs = pkgs; }) ../home/programs/beets ]; diff --git a/nix/home/programs/flood/default.nix b/nix/home/programs/flood/default.nix deleted file mode 100644 index ebfb3fd..0000000 --- a/nix/home/programs/flood/default.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ pkgs, ... }: -{ - networking.firewall = { - allowedTCPPorts = [ - #nginx - 80 - 443 - ]; - }; - - services.nginx = { - enable = true; - virtualHosts."torrents" = { - locations."/" = { - proxyPass = "http://localhost:3000"; - }; - }; - }; - - users.users.flood.group = "flood"; - users.extraUsers.flood = { - isNormalUser = true; - extraGroups = [ "rtorrent" "users" ]; - }; - - systemd.services = { - flood = { - enable = true; - serviceConfig = { - User = "flood"; - WorkingDirectory = "/home/flood"; - ExecStart = "${pkgs.flood}/bin/flood"; - Restart = "on-failure"; - }; - wantedBy = [ "multi-user.target" ]; - after = [ "network.target" "rtorrent.service" ]; - }; - }; -} diff --git a/nix/home/programs/qbittorrent/default.nix b/nix/home/programs/qbittorrent/default.nix index af87fe5..d2d6010 100644 --- a/nix/home/programs/qbittorrent/default.nix +++ b/nix/home/programs/qbittorrent/default.nix @@ -2,6 +2,13 @@ { environment.systemPackages = with pkgs; [ qbittorrent-nox ]; + users.groups.qbittorrent = { }; + users.users.qbittorrent.group = "qbittorrent"; + users.extraUsers.qbittorrent = { + isNormalUser = true; + extraGroups = [ "users" "multimedia" ]; + }; + systemd = { packages = [ pkgs.qbittorrent-nox ]; @@ -9,7 +16,7 @@ enable = true; serviceConfig = { Type = "simple"; - User = "rtorrent"; + User = "qbittorrent"; ExecStart = "${pkgs.qbittorrent-nox}/bin/qbittorrent-nox"; }; wantedBy = [ "multi-user.target" ]; diff --git a/nix/home/programs/rtorrent/default.nix b/nix/home/programs/rtorrent/default.nix deleted file mode 100644 index 25b8c7b..0000000 --- a/nix/home/programs/rtorrent/default.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ pkgs, finalDir, downloadDir, watchDir }: -let - # this needs to be configured in mullvad's settings - dhtPort = 55358; - rtorrentPort = 54945; -in -{ - - environment.systemPackages = with pkgs; [ rtorrent ]; - - users.extraUsers.rtorrent.extraGroups = [ "users" ]; - - services.rtorrent = { - enable = true; - port = rtorrentPort; - openFirewall = true; - downloadDir = downloadDir; - # flood needs to be able to access the datadir - dataDir = downloadDir; - configText = - builtins.readFile (pkgs.substituteAll { - src = ./rtorrent.rc; - watchDir = watchDir; - finalDir = finalDir; - dhtPort = builtins.toString dhtPort; - }); - }; - - networking.firewall = { - allowedTCPPorts = [ - dhtPort - ]; - allowedUDPPorts = [ - dhtPort - rtorrentPort - ]; - }; -} diff --git a/nix/home/programs/rtorrent/rtorrent.rc b/nix/home/programs/rtorrent/rtorrent.rc deleted file mode 100644 index 70bb0f5..0000000 --- a/nix/home/programs/rtorrent/rtorrent.rc +++ /dev/null @@ -1,85 +0,0 @@ -# Set an interface with IPv4 address to bind to: -method.insert = cfg.interface.bind, string|const|private, (cat,"wg0") -# Get IPv4 address of a given interface -method.insert = get_interface_ipv4_address, simple|private, "execute.capture=bash,-c,\"$cat=\\\"echo -n \$(ip -o -4 addr show \\\",$argument.0=,\\\" | grep -Po 'inet \\\\\\\\\\K[\\\\\\\\\\d.]+')\\\"\"" -# The IP address the listening socket and outgoing connections is bound to. (bind) -schedule2 = set_bind_address, 0, 0, \ - "branch=((cfg.interface.bind)), \ - ((network.bind_address.set,(get_interface_ipv4_address,(cfg.interface.bind))))" - -# Port range to use for listening. (port_range) -network.port_range.set = @dhtPort@-@dhtPort@ - -# Enable/disable peer exchange for torrents that aren't marked private. Disabled by default. (peer_exchange) -protocol.pex.set = 1 - -# Set whether the client should try to connect to UDP trackers (It can cause various problems if it's enabled, if you experience any with this option enabled then disable it.) -trackers.use_udp.set = 1 - -# Enable DHT support for trackerless torrents or when all trackers are down. -# May be set to "disable" (completely disable DHT), "off" (do not start DHT), -# "auto" (start and stop DHT as needed), or "on" (start DHT immediately). -# The default is "off". -# For DHT to work, a session directory must be defined. -dht.mode.set = auto -dht.port.set = @dhtPort@ - -throttle.max_uploads.set = 100 -throttle.max_uploads.global.set = 250 - -throttle.min_peers.normal.set = 1 -throttle.max_peers.normal.set = 1024 -throttle.min_peers.seed.set = 1 -throttle.max_peers.seed.set = 1024 -trackers.numwant.set = 80 - -# Adding public DHT servers for easy bootstrapping -schedule2 = dht_node_1, 5, 0, "dht.add_node=router.utorrent.com:6881" -schedule2 = dht_node_2, 5, 0, "dht.add_node=dht.transmissionbt.com:6881" -schedule2 = dht_node_3, 5, 0, "dht.add_node=router.bitcomet.com:6881" -schedule2 = dht_node_4, 5, 0, "dht.add_node=dht.aelitis.com:6881" - -# 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 - -# To ensure world-readable results -system.umask.set = 0000 - -# 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/svalbard/configuration.nix b/nix/system/svalbard/configuration.nix index f776c85..4c9eed1 100644 --- a/nix/system/svalbard/configuration.nix +++ b/nix/system/svalbard/configuration.nix @@ -10,13 +10,6 @@ # 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"; - }) - (import ../../home/programs/qbittorrent { pkgs = pkgs; }) ]; # Bootloader.