nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 makeWrapper,
6 nixosTests,
7 systemdLibs,
8 withSystemdSupport ? true,
9}:
10
11buildGoModule rec {
12 pname = "postfix_exporter";
13 version = "0.18.0";
14
15 src = fetchFromGitHub {
16 owner = "Hsn723";
17 repo = "postfix_exporter";
18 tag = "v${version}";
19 sha256 = "sha256-xpzYhdmryUV3RKGgvqJkTpi3mv/0LMHoMiAZX+i0BmI=";
20 };
21
22 vendorHash = "sha256-3jZWyaLoSAqjutmKp1RowvLuFVNnp+Vz+v8jL7fvzbo=";
23
24 ldflags = [
25 "-s"
26 "-w"
27 ];
28
29 nativeBuildInputs = lib.optionals withSystemdSupport [ makeWrapper ];
30 buildInputs = lib.optionals withSystemdSupport [ systemdLibs ];
31 tags = lib.optionals (!withSystemdSupport) "nosystemd";
32
33 postInstall = lib.optionals withSystemdSupport ''
34 wrapProgram $out/bin/postfix_exporter \
35 --prefix LD_LIBRARY_PATH : "${lib.getLib systemdLibs}/lib"
36 '';
37
38 passthru.tests = { inherit (nixosTests.prometheus-exporters) postfix; };
39
40 meta = {
41 inherit (src.meta) homepage;
42 description = "Prometheus exporter for Postfix";
43 mainProgram = "postfix_exporter";
44 license = lib.licenses.asl20;
45 maintainers = with lib.maintainers; [
46 globin
47 ];
48 };
49}