summaryrefslogtreecommitdiff
path: root/overlays/zte-prometheus-exporter/default.nix
blob: 2188e7b370ddc1c136e0f99477b7fcedbe54b077 (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
    '';
  };
}