From 4e17989a59312ec8e55d05668afec0deab692a31 Mon Sep 17 00:00:00 2001 From: pazpi Date: Fri, 16 Aug 2024 18:20:48 +0200 Subject: [PATCH] Moved some files --- lxc-nix/modules/qbittorrent.nix | 126 ------------------ lxc-nix/packages/rutorrent.nix | 27 ---- lxc-nix/services/qbittorrent.nix | 29 ---- lxc-nix/services/rutorrent.nix | 1 - .../services}/rutorrent.nix | 0 5 files changed, 183 deletions(-) delete mode 100644 lxc-nix/modules/qbittorrent.nix delete mode 100644 lxc-nix/packages/rutorrent.nix delete mode 100644 lxc-nix/services/qbittorrent.nix rename {lxc-nix/modules => modules/services}/rutorrent.nix (100%) diff --git a/lxc-nix/modules/qbittorrent.nix b/lxc-nix/modules/qbittorrent.nix deleted file mode 100644 index b319c9b..0000000 --- a/lxc-nix/modules/qbittorrent.nix +++ /dev/null @@ -1,126 +0,0 @@ -{ config, lib, pkgs, ... }: - -with lib; - -let - cfg = config.services.qbittorrent; - UID = 888; - GID = 888; -in -{ - options.services.qbittorrent = { - enable = mkEnableOption (lib.mdDoc "qBittorrent headless"); - - dataDir = mkOption { - type = types.path; - default = "/var/lib/qbittorrent"; - description = lib.mdDoc '' - The directory where qBittorrent stores its data files. - ''; - }; - - user = mkOption { - type = types.str; - default = "qbittorrent"; - description = lib.mdDoc '' - User account under which qBittorrent runs. - ''; - }; - - group = mkOption { - type = types.str; - default = "qbittorrent"; - description = lib.mdDoc '' - Group under which qBittorrent runs. - ''; - }; - - port = mkOption { - type = types.port; - default = 8080; - description = lib.mdDoc '' - qBittorrent web UI port. - ''; - }; - - openFirewall = mkOption { - type = types.bool; - default = false; - description = lib.mdDoc '' - Open services.qBittorrent.port to the outside network. - ''; - }; - - package = mkOption { - type = types.package; - default = pkgs.qbittorrent-nox; - defaultText = literalExpression "pkgs.qbittorrent-nox"; - description = lib.mdDoc '' - The qbittorrent package to use. - ''; - }; - }; - - config = mkIf cfg.enable { - networking.firewall = mkIf cfg.openFirewall { - allowedTCPPorts = [ cfg.port ]; - }; - - systemd.services.qbittorrent = { - # based on the plex.nix service module and - # https://github.com/qbittorrent/qBittorrent/blob/master/dist/unix/systemd/qbittorrent-nox%40.service.in - description = "qBittorrent-nox service"; - documentation = [ "man:qbittorrent-nox(1)" ]; - after = [ "network.target" ]; - wantedBy = [ "multi-user.target" ]; - - serviceConfig = { - Type = "simple"; - User = cfg.user; - Group = cfg.group; - - # Run the pre-start script with full permissions (the "!" prefix) so it - # can create the data directory if necessary. - ExecStartPre = - let - preStartScript = pkgs.writeScript "qbittorrent-run-prestart" '' - #!${pkgs.bash}/bin/bash - - # Create data directory if it doesn't exist - if ! test -d "$QBT_PROFILE"; then - echo "Creating initial qBittorrent data directory in: $QBT_PROFILE" - install -d -m 0755 -o "${cfg.user}" -g "${cfg.group}" "$QBT_PROFILE" - fi - ''; - in - "!${preStartScript}"; - - #ExecStart = "${pkgs.qbittorrent-nox}/bin/qbittorrent-nox"; - ExecStart = "${cfg.package}/bin/qbittorrent-nox"; - # To prevent "Quit & shutdown daemon" from working; we want systemd to - # manage it! - #Restart = "on-success"; - #UMask = "0002"; - #LimitNOFILE = cfg.openFilesLimit; - }; - - environment = { - QBT_PROFILE = cfg.dataDir; - QBT_WEBUI_PORT = toString cfg.port; - QBT_EULA = "accept"; - # QBT_EULA = toString cfg.acceptEula; - }; - }; - - # users.users = mkIf (cfg.user == "qbittorrent") { - # qbittorrent = { - # group = cfg.group; - # uid = UID; - # }; - # }; - - # users.groups = mkIf (cfg.group == "qbittorrent") { - # qbittorrent = { gid = GID; }; - # }; - }; -} diff --git a/lxc-nix/packages/rutorrent.nix b/lxc-nix/packages/rutorrent.nix deleted file mode 100644 index 791c2f1..0000000 --- a/lxc-nix/packages/rutorrent.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ pkgs ? import { }, lib, }: - -with pkgs; - -stdenv.mkDerivation rec { - pname = "rutorrent"; - version = "4.3.6"; - - src = fetchFromGitHub { - owner = "Novik"; - repo = "ruTorrent"; - rev = "v${version}"; - sha256 = "sha256-pwmMH3ZwwAzuyVCJAPfTcSdvUP3HPRVpUSEROMD7XfE="; - }; - - installPhase = '' - mkdir -p $out/ - cp -r . $out/ - ''; - - meta = with lib; { - description = "Yet another web front-end for rTorrent"; - homepage = "https://github.com/Novik/ruTorrent"; - license = licenses.gpl3Plus; - platforms = platforms.unix; - }; -} diff --git a/lxc-nix/services/qbittorrent.nix b/lxc-nix/services/qbittorrent.nix deleted file mode 100644 index 36114e6..0000000 --- a/lxc-nix/services/qbittorrent.nix +++ /dev/null @@ -1,29 +0,0 @@ -# qBittorrent service activation -# -# The shell script 'fixdlperms' is also created and should be added to the -# "Run external program on finished" section with the full path: -# /run/current-system/sw/bin/fixdlperms - -{ pkgs, ... }: - -let - downloadDir = "/data/multimedia/downloads"; - fixDownloadPerms = pkgs.writeShellScriptBin "fixdlperms" '' - find ${downloadDir} -type d -exec chmod 2775 {} + - find ${downloadDir} -type f -exec chmod 0664 {} + - ''; -in -{ - services.qbittorrent = { - enable = true; - openFirewall = true; - dataDir = "/srv/qbittorrent"; - port = 58080; - user = "qbittorrent"; - }; - - # Allow qbittorrent to save files in the multimedia share - # users.users.qbittorrent.extraGroups = [ "multimedia" ]; - - environment.systemPackages = [ fixDownloadPerms ]; -} diff --git a/lxc-nix/services/rutorrent.nix b/lxc-nix/services/rutorrent.nix index 166a3f2..0983f3f 100644 --- a/lxc-nix/services/rutorrent.nix +++ b/lxc-nix/services/rutorrent.nix @@ -61,7 +61,6 @@ in ]; nginx = { enable = true; - # exposeInsecureRPC2mount = true; }; }; diff --git a/lxc-nix/modules/rutorrent.nix b/modules/services/rutorrent.nix similarity index 100% rename from lxc-nix/modules/rutorrent.nix rename to modules/services/rutorrent.nix