1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8let 9 cfg = config.services.prometheus.exporters.deluge; 10 inherit (lib) mkOption types concatStringsSep; 11in 12{ 13 port = 9354; 14 15 extraOpts = { 16 delugeHost = mkOption { 17 type = types.str; 18 default = "localhost"; 19 description = '' 20 Hostname where deluge server is running. 21 ''; 22 }; 23 24 delugePort = mkOption { 25 type = types.port; 26 default = 58846; 27 description = '' 28 Port where deluge server is listening. 29 ''; 30 }; 31 32 delugeUser = mkOption { 33 type = types.str; 34 default = "localclient"; 35 description = '' 36 User to connect to deluge server. 37 ''; 38 }; 39 40 delugePassword = mkOption { 41 type = types.nullOr types.str; 42 default = null; 43 description = '' 44 Password to connect to deluge server. 45 46 This stores the password unencrypted in the nix store and is thus considered unsafe. Prefer 47 using the delugePasswordFile option. 48 ''; 49 }; 50 51 delugePasswordFile = mkOption { 52 type = types.nullOr types.path; 53 default = null; 54 description = '' 55 File containing the password to connect to deluge server. 56 ''; 57 }; 58 59 exportPerTorrentMetrics = mkOption { 60 type = types.bool; 61 default = false; 62 description = '' 63 Enable per-torrent metrics. 64 65 This may significantly increase the number of time series depending on the number of 66 torrents in your Deluge instance. 67 ''; 68 }; 69 }; 70 serviceOpts = { 71 serviceConfig = { 72 ExecStart = '' 73 ${pkgs.prometheus-deluge-exporter}/bin/deluge-exporter 74 ''; 75 Environment = [ 76 "LISTEN_PORT=${toString cfg.port}" 77 "LISTEN_ADDRESS=${toString cfg.listenAddress}" 78 79 "DELUGE_HOST=${cfg.delugeHost}" 80 "DELUGE_USER=${cfg.delugeUser}" 81 "DELUGE_PORT=${toString cfg.delugePort}" 82 ] 83 ++ lib.optionals (cfg.delugePassword != null) [ 84 "DELUGE_PASSWORD=${cfg.delugePassword}" 85 ] 86 ++ lib.optionals cfg.exportPerTorrentMetrics [ 87 "PER_TORRENT_METRICS=1" 88 ]; 89 EnvironmentFile = lib.optionalString ( 90 cfg.delugePasswordFile != null 91 ) "/etc/deluge-exporter/password"; 92 }; 93 }; 94}