1{ config, lib, pkgs, options }: 2 3with lib; 4 5let 6 cfg = config.services.prometheus.exporters.nextcloud; 7in 8{ 9 port = 9205; 10 extraOpts = { 11 url = mkOption { 12 type = types.str; 13 example = "https://domain.tld"; 14 description = lib.mdDoc '' 15 URL to the Nextcloud serverinfo page. 16 Adding the path to the serverinfo API is optional, it defaults 17 to `/ocs/v2.php/apps/serverinfo/api/v1/info`. 18 ''; 19 }; 20 username = mkOption { 21 type = types.str; 22 default = "nextcloud-exporter"; 23 description = lib.mdDoc '' 24 Username for connecting to Nextcloud. 25 Note that this account needs to have admin privileges in Nextcloud. 26 Unused when using token authentication. 27 ''; 28 }; 29 passwordFile = mkOption { 30 type = types.nullOr types.path; 31 default = null; 32 example = "/path/to/password-file"; 33 description = lib.mdDoc '' 34 File containing the password for connecting to Nextcloud. 35 Make sure that this file is readable by the exporter user. 36 ''; 37 }; 38 tokenFile = mkOption { 39 type = types.nullOr types.path; 40 default = null; 41 example = "/path/to/token-file"; 42 description = lib.mdDoc '' 43 File containing the token for connecting to Nextcloud. 44 Make sure that this file is readable by the exporter user. 45 ''; 46 }; 47 timeout = mkOption { 48 type = types.str; 49 default = "5s"; 50 description = lib.mdDoc '' 51 Timeout for getting server info document. 52 ''; 53 }; 54 }; 55 serviceOpts = { 56 serviceConfig = { 57 DynamicUser = false; 58 ExecStart = '' 59 ${pkgs.prometheus-nextcloud-exporter}/bin/nextcloud-exporter \ 60 --addr ${cfg.listenAddress}:${toString cfg.port} \ 61 --timeout ${cfg.timeout} \ 62 --server ${cfg.url} \ 63 ${if cfg.passwordFile != null then '' 64 --username ${cfg.username} \ 65 --password ${escapeShellArg "@${cfg.passwordFile}"} \ 66 '' else '' 67 --auth-token ${escapeShellArg "@${cfg.tokenFile}"} \ 68 ''} \ 69 ${concatStringsSep " \\\n " cfg.extraFlags}''; 70 }; 71 }; 72}