forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request NixOS#265696 from Stunkymonkey/nixos-exportarr
nixos/exportarr: init
- Loading branch information
Showing
4 changed files
with
110 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
nixos/modules/services/monitoring/prometheus/exporters/exportarr.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ config, lib, pkgs, options, type }: | ||
|
||
let | ||
cfg = config.services.prometheus.exporters."exportarr-${type}"; | ||
exportarrEnvironment = ( | ||
lib.mapAttrs (_: toString) cfg.environment | ||
) // { | ||
PORT = toString cfg.port; | ||
URL = cfg.url; | ||
API_KEY_FILE = lib.mkIf (cfg.apiKeyFile != null) "%d/api-key"; | ||
}; | ||
in | ||
{ | ||
port = 9708; | ||
extraOpts = { | ||
url = lib.mkOption { | ||
type = lib.types.str; | ||
default = "http://127.0.0.1"; | ||
description = lib.mdDoc '' | ||
The full URL to Sonarr, Radarr, or Lidarr. | ||
''; | ||
}; | ||
|
||
apiKeyFile = lib.mkOption { | ||
type = lib.types.nullOr lib.types.path; | ||
default = null; | ||
description = lib.mdDoc '' | ||
File containing the api-key. | ||
''; | ||
}; | ||
|
||
package = lib.mkPackageOptionMD pkgs "exportarr" { }; | ||
|
||
environment = lib.mkOption { | ||
type = lib.types.attrsOf lib.types.str; | ||
default = { }; | ||
description = lib.mdDoc '' | ||
See [the configuration guide](https://github.com/onedr0p/exportarr#configuration) for available options. | ||
''; | ||
example = { | ||
PROWLARR__BACKFILL = true; | ||
}; | ||
}; | ||
}; | ||
serviceOpts = { | ||
serviceConfig = { | ||
LoadCredential = lib.optionalString (cfg.apiKeyFile != null) "api-key:${cfg.apiKeyFile}"; | ||
ExecStart = ''${cfg.package}/bin/exportarr ${type} "$@"''; | ||
ProcSubset = "pid"; | ||
ProtectProc = "invisible"; | ||
SystemCallFilter = ["@system-service" "~@privileged"]; | ||
}; | ||
environment = exportarrEnvironment; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters