From e7a2d8aa18770a1ac2a2073a563ee298e7e7d90a Mon Sep 17 00:00:00 2001 From: MinerSebas <scherthan_sebastian@web.de> Date: Fri, 2 Feb 2024 14:41:45 +0100 Subject: [PATCH 1/2] prometheus-restic-exporter: 1.4.0 -> 1.5.0 --- .../services/monitoring/prometheus/exporters/restic.nix | 4 ++-- pkgs/by-name/pr/prometheus-restic-exporter/package.nix | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/monitoring/prometheus/exporters/restic.nix b/nixos/modules/services/monitoring/prometheus/exporters/restic.nix index 5b32c93a666d..fabcff0430ed 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters/restic.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters/restic.nix @@ -108,8 +108,8 @@ in toRcloneVal = v: if lib.isBool v then lib.boolToString v else v; in { - RESTIC_REPO_URL = cfg.repository; - RESTIC_REPO_PASSWORD_FILE = cfg.passwordFile; + RESTIC_REPOSITORY = cfg.repository; + RESTIC_PASSWORD_FILE = cfg.passwordFile; LISTEN_ADDRESS = cfg.listenAddress; LISTEN_PORT = toString cfg.port; REFRESH_INTERVAL = toString cfg.refreshInterval; diff --git a/pkgs/by-name/pr/prometheus-restic-exporter/package.nix b/pkgs/by-name/pr/prometheus-restic-exporter/package.nix index 4e3736a573b6..603650a66ab6 100644 --- a/pkgs/by-name/pr/prometheus-restic-exporter/package.nix +++ b/pkgs/by-name/pr/prometheus-restic-exporter/package.nix @@ -8,13 +8,13 @@ stdenvNoCC.mkDerivation rec { pname = "prometheus-restic-exporter"; - version = "1.4.0"; + version = "1.5.0"; src = fetchFromGitHub { owner = "ngosang"; repo = "restic-exporter"; rev = version; - hash = "sha256-Qwhlecginl5+V+iddN/vIHfJA1kQOZtscECsoD4LJPE="; + hash = "sha256-SC2ZCIQ33RaFI9+l/WI6edNzGEtsxJ2bBdeGNMHuyqY="; }; buildInputs = [ @@ -26,7 +26,7 @@ stdenvNoCC.mkDerivation rec { install -D -m0755 restic-exporter.py $out/bin/restic-exporter.py - substituteInPlace $out/bin/restic-exporter.py --replace \"restic\" \"${lib.makeBinPath [ restic ]}/restic\" + substituteInPlace $out/bin/restic-exporter.py --replace-fail \"restic\" \"${lib.makeBinPath [ restic ]}/restic\" patchShebangs $out/bin/restic-exporter.py From de306fb3d64f5086fbf63fec1d104f7187512b0d Mon Sep 17 00:00:00 2001 From: MinerSebas <scherthan_sebastian@web.de> Date: Fri, 2 Feb 2024 14:43:22 +0100 Subject: [PATCH 2/2] nixos/prometheus-restic-exporter: Use LoadCredential for password file --- .../monitoring/prometheus/exporters/restic.nix | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/monitoring/prometheus/exporters/restic.nix b/nixos/modules/services/monitoring/prometheus/exporters/restic.nix index fabcff0430ed..977bd42e9812 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters/restic.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters/restic.nix @@ -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;