···
{ config, lib, pkgs, ... }:
cfg = config.services.deluge;
cfg_web = config.services.deluge.web;
8
-
isDeluge1 = versionOlder cfg.package.version "2.0.0";
5
+
isDeluge1 = lib.versionOlder cfg.package.version "2.0.0";
listenPortsDefault = [ 6881 6889 ];
13
-
listToRange = x: { from = elemAt x 0; to = elemAt x 1; };
10
+
listToRange = x: { from = lib.elemAt x 0; to = lib.elemAt x 1; };
configDir = "${cfg.dataDir}/.config/deluge";
configFile = pkgs.writeText "core.conf" (builtins.toJSON cfg.config);
···
40
-
enable = mkEnableOption "Deluge daemon";
37
+
enable = lib.mkEnableOption "Deluge daemon";
42
-
openFilesLimit = mkOption {
39
+
openFilesLimit = lib.mkOption {
default = openFilesLimit;
44
-
type = types.either types.int types.str;
41
+
type = lib.types.either lib.types.int lib.types.str;
Number of files to allow deluged to open.
47
+
config = lib.mkOption {
48
+
type = lib.types.attrs;
53
-
example = literalExpression ''
50
+
example = lib.literalExpression ''
download_location = "/srv/torrents/";
max_upload_speed = "1000.0";
···
73
-
declarative = mkOption {
70
+
declarative = lib.mkOption {
71
+
type = lib.types.bool;
Whether to use a declarative deluge configuration.
···
86
-
openFirewall = mkOption {
83
+
openFirewall = lib.mkOption {
85
+
type = lib.types.bool;
Whether to open the firewall for the ports in
{option}`services.deluge.config.listen_ports`. It only takes effet if
···
102
-
dataDir = mkOption {
99
+
dataDir = lib.mkOption {
100
+
type = lib.types.path;
default = "/var/lib/deluge";
The directory where deluge will create files.
110
-
authFile = mkOption {
107
+
authFile = lib.mkOption {
108
+
type = lib.types.path;
example = "/run/keys/deluge-auth";
The file managing the authentication for deluge, the format of this
···
121
+
user = lib.mkOption {
122
+
type = lib.types.str;
User account under which deluge runs.
129
+
group = lib.mkOption {
130
+
type = lib.types.str;
Group under which deluge runs.
140
-
extraPackages = mkOption {
141
-
type = types.listOf types.package;
137
+
extraPackages = lib.mkOption {
138
+
type = lib.types.listOf lib.types.package;
Extra packages available at runtime to enable Deluge's plugins. For example,
···
150
-
package = mkPackageOption pkgs "deluge-2_x" { };
147
+
package = lib.mkPackageOption pkgs "deluge-2_x" { };
154
-
enable = mkEnableOption "Deluge Web daemon";
151
+
enable = lib.mkEnableOption "Deluge Web daemon";
153
+
port = lib.mkOption {
154
+
type = lib.types.port;
164
-
openFirewall = mkOption {
161
+
openFirewall = lib.mkOption {
162
+
type = lib.types.bool;
Open ports in the firewall for deluge web daemon
···
175
-
config = mkIf cfg.enable {
172
+
config = lib.mkIf cfg.enable {
177
-
services.deluge.package = mkDefault (
178
-
if versionAtLeast config.system.stateVersion "20.09" then
174
+
services.deluge.package = lib.mkDefault (
175
+
if lib.versionAtLeast config.system.stateVersion "20.09" then
# deluge-1_x is no longer packaged and this will resolve to an error
···
"${cfg.dataDir}/.config".d = defaultConfig;
"${cfg.dataDir}/.config/deluge".d = defaultConfig;
204
-
// optionalAttrs (cfg.config ? download_location) {
201
+
// lib.optionalAttrs (cfg.config ? download_location) {
${cfg.config.download_location}.d = defaultConfig;
207
-
// optionalAttrs (cfg.config ? torrentfiles_location) {
204
+
// lib.optionalAttrs (cfg.config ? torrentfiles_location) {
${cfg.config.torrentfiles_location}.d = defaultConfig;
210
-
// optionalAttrs (cfg.config ? move_completed_path) {
207
+
// lib.optionalAttrs (cfg.config ? move_completed_path) {
${cfg.config.move_completed_path}.d = defaultConfig;
···
236
-
systemd.services.delugeweb = mkIf cfg_web.enable {
233
+
systemd.services.delugeweb = lib.mkIf cfg_web.enable {
after = [ "network.target" "deluged.service"];
requires = [ "deluged.service" ];
description = "Deluge BitTorrent WebUI";
···
${cfg.package}/bin/deluge-web \
245
-
${optionalString (!isDeluge1) "--do-not-daemonize"} \
242
+
${lib.optionalString (!isDeluge1) "--do-not-daemonize"} \
--port ${toString cfg.web.port}
···
254
-
networking.firewall = mkMerge [
255
-
(mkIf (cfg.declarative && cfg.openFirewall && !(cfg.config.random_port or true)) {
256
-
allowedTCPPortRanges = singleton (listToRange (cfg.config.listen_ports or listenPortsDefault));
257
-
allowedUDPPortRanges = singleton (listToRange (cfg.config.listen_ports or listenPortsDefault));
251
+
networking.firewall = lib.mkMerge [
252
+
(lib.mkIf (cfg.declarative && cfg.openFirewall && !(cfg.config.random_port or true)) {
253
+
allowedTCPPortRanges = lib.singleton (listToRange (cfg.config.listen_ports or listenPortsDefault));
254
+
allowedUDPPortRanges = lib.singleton (listToRange (cfg.config.listen_ports or listenPortsDefault));
259
-
(mkIf (cfg.web.openFirewall) {
256
+
(lib.mkIf (cfg.web.openFirewall) {
allowedTCPPorts = [ cfg.web.port ];
environment.systemPackages = [ cfg.package ];
266
-
users.users = mkIf (cfg.user == "deluge") {
263
+
users.users = lib.mkIf (cfg.user == "deluge") {
uid = config.ids.uids.deluge;
···
275
-
users.groups = mkIf (cfg.group == "deluge") {
272
+
users.groups = lib.mkIf (cfg.group == "deluge") {
gid = config.ids.gids.deluge;