about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/pr/prometheus-restic-exporter/package.nix
blob: 603650a66ab6375f69db81170980c8f5e66912e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{ lib
, stdenvNoCC
, fetchFromGitHub
, python3
, restic
, nixosTests
}:

stdenvNoCC.mkDerivation rec {
  pname = "prometheus-restic-exporter";
  version = "1.5.0";

  src = fetchFromGitHub {
    owner = "ngosang";
    repo = "restic-exporter";
    rev = version;
    hash = "sha256-SC2ZCIQ33RaFI9+l/WI6edNzGEtsxJ2bBdeGNMHuyqY=";
  };

  buildInputs = [
    (python3.withPackages (ps: [ ps.prometheus-client ]))
  ];

  installPhase = ''
    runHook preInstall

    install -D -m0755 restic-exporter.py $out/bin/restic-exporter.py

    substituteInPlace $out/bin/restic-exporter.py --replace-fail \"restic\" \"${lib.makeBinPath [ restic ]}/restic\"

    patchShebangs $out/bin/restic-exporter.py

    runHook postInstall
  '';

  passthru.tests = {
    restic-exporter = nixosTests.prometheus-exporters.restic;
  };

  meta = with lib; {
    description = "Prometheus exporter for the Restic backup system";
    homepage = "https://github.com/ngosang/restic-exporter";
    changelog = "https://github.com/ngosang/restic-exporter/blob/${src.rev}/CHANGELOG.md";
    license = licenses.mit;
    maintainers = with maintainers; [ minersebas ];
    mainProgram = "restic-exporter.py";
    platforms = platforms.all;
  };
}