ctucx.git: fritzbox-exporter

[nimlang] prometheus exporter for lte fritzboxes

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 
let
  crossPkgs = import <nixpkgs> {
    crossSystem = {
      config = "mips-unknown-linux-musl";
      platform = {
        name = "fritzbox";
        kernelMajor = "4.4";
        kernelArch = "mips";
        gcc = {
          arch = "mips32";
          float = "soft";
        };
      };
    };

    crossOverlays = [
      (import <nixpkgs/pkgs/top-level/static.nix>)
    ];

    overlays = [
      (self: super: rec {
      })
    ];

    config.allowUnsupportedSystem = true;
  };

  pkgs = import <nixpkgs> {};

in crossPkgs.stdenv.mkDerivation {
  name = "fritzbox-exporter";

  nativeBuildInputs = [ pkgs.nim ];
  src = ./.;

  buildPhase = ''
    runHook preBuild
    nim c --cpu:mips -d:release --nimcache:$PWD src/fb_exporter_client.nim
    runHook postBuild
  '';
  installPhase = ''
    runHook preInstall
    install -Dm755 src/fb_exporter_client $out/bin/fb_exporter_client
    runHook postInstall
  '';
}