summaryrefslogtreecommitdiff
path: root/overlays/zte-prometheus-exporter/default.nix
blob: 1609724bf7f74501f3edb4ac6f1eee86ec3a896f (plain)
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
final: prev:
let
  packageOverrides = final.callPackage ./python-packages.nix {};
  inpPython = final.python310.override { inherit packageOverrides; };
in {
  zte-prometheus-exporter = prev.stdenv.mkDerivation rec {
    name = "zte-prometheus-exporter";
    src = ./zte-prometheus-exporter.py;

    phases = [ "buildPhase" "checkPhase" "installPhase" ];

    python = inpPython.withPackages (ps: with ps; [pytimeparse requests]);

    buildPhase = ''
      substituteAll $src zte-prometheus-exporter
    '';

    doCheck = true;
    checkPhase = ''
      ${python}/bin/python -m py_compile zte-prometheus-exporter
    '';

    installPhase = ''
      install -m 0755 -D -t $out/bin \
        zte-prometheus-exporter
    '';
  };
}