Nix configurations for my homelab
0

Configure Feed

Select the types of activity you want to include in your feed.

1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7{ 8 environment.persistence."/data/persistent".directories = [ 9 { 10 directory = "/var/lib/qBittorrent"; 11 mode = "0700"; 12 user = "qbittorrent"; 13 group = "qbittorrent"; 14 } 15 ]; 16 17 networking.firewall.interfaces.${config.services.netbird.clients.homelab.interface}.allowedTCPPorts = lib.mkIf ( 18 config.networking.hostName == "lily" 19 ) [ 8082 ]; 20 21 users = { 22 users.qbittorrent = { 23 group = "qbittorrent"; 24 isSystemUser = true; 25 uid = 998; 26 }; 27 groups.qbittorrent.gid = 998; 28 }; 29 30 containers.vpn = { 31 bindMounts = { 32 torrents = { 33 hostPath = "/data/torrents"; 34 mountPoint = "/torrents"; 35 isReadOnly = false; 36 }; 37 qbittorrent = { 38 hostPath = "/var/lib/qBittorrent"; 39 mountPoint = "/var/lib/qBittorrent"; 40 isReadOnly = false; 41 }; 42 }; 43 forwardPorts = lib.mkIf (config.networking.hostName == "lily") [ 44 { 45 hostPort = 8082; 46 containerPort = 8082; 47 } 48 ]; 49 }; 50 51 garden.container.vpn.config = [ 52 { 53 networking.firewall.allowedTCPPorts = [ 8082 ]; 54 55 systemd.services.protonvpn-qbittorrent-natpmp = { 56 description = "Get a port and provide it to qBittorrent"; 57 requires = [ 58 "network-online.target" 59 "qbittorrent.service" 60 ]; 61 wantedBy = [ "multi-user.target" ]; 62 serviceConfig = { 63 ExecStart = "${ 64 pkgs.writeShellApplication { 65 name = "protonvpn-natpmp"; 66 runtimeInputs = with pkgs; [ 67 curl 68 gnugrep 69 jq 70 libnatpmp 71 ]; 72 text = builtins.readFile ../scripts/protonvpn-natpmp.sh; 73 } 74 }/bin/protonvpn-natpmp"; 75 Restart = "on-failure"; 76 }; 77 }; 78 79 services.qbittorrent = { 80 enable = true; 81 webuiPort = 8082; 82 serverConfig = { 83 LegalNotice.Accepted = true; 84 BitTorrent = { 85 ExcludedFileNamesEnabled = true; 86 Session = { 87 DefaultSavePath = "/torrents"; 88 ExcludedFileNames = lib.strings.join ", " [ 89 "*.exe" 90 "*.scr" 91 ]; 92 Interface = "vpn"; 93 InterfaceName = "vpn"; 94 TorrentContentLayout = "Subfolder"; 95 Preallocation = true; 96 QueueingSystemEnabled = false; 97 GlobalMaxInactiveSeedingMinutes = 61 * 24 * 60; 98 GlobalMaxSeedingMinutes = 31 * 24 * 60; 99 MaxConnections = 500; 100 MaxConnectionsPerTorrent = 100; 101 MaxUploads = -1; 102 MaxUploadsPerTorrent = 25; 103 ShareLimitAction = "Stop"; 104 }; 105 }; 106 Network.PortForwardingEnabled = false; 107 Preferences = { 108 General = { 109 DeleteTorrentsFilesAsDefault = true; 110 StatusbarExternalIPDisplayed = true; 111 }; 112 WebUI = { 113 LocalHostAuth = false; 114 AuthSubnetWhitelistEnabled = true; 115 AuthSubnetWhitelist = lib.strings.join ", " [ 116 "192.168.2.1/32" 117 (lib.optionalString (config.networking.hostName == "lily") "${config.garden.info.network.lutea.netbird-ip}/32") 118 ]; 119 }; 120 }; 121 }; 122 }; 123 } 124 ]; 125}