nixos/prometheus-restic-exporter: Use LoadCredential for password file

This commit is contained in:
MinerSebas 2024-02-02 14:43:22 +01:00
parent e7a2d8aa18
commit de306fb3d6

View File

@ -93,12 +93,14 @@ in
};
serviceOpts = {
script = ''
export RESTIC_PASSWORD_FILE=$CREDENTIALS_DIRECTORY/RESTIC_PASSWORD_FILE
${pkgs.prometheus-restic-exporter}/bin/restic-exporter.py \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
serviceConfig = {
ExecStart = ''
${pkgs.prometheus-restic-exporter}/bin/restic-exporter.py \
${concatStringsSep " \\\n " cfg.extraFlags}
'';
EnvironmentFile = mkIf (cfg.environmentFile != null) cfg.environmentFile;
LoadCredential = [ "RESTIC_PASSWORD_FILE:${cfg.passwordFile}" ];
};
environment =
let
@ -109,7 +111,6 @@ in
in
{
RESTIC_REPOSITORY = cfg.repository;
RESTIC_PASSWORD_FILE = cfg.passwordFile;
LISTEN_ADDRESS = cfg.listenAddress;
LISTEN_PORT = toString cfg.port;
REFRESH_INTERVAL = toString cfg.refreshInterval;