2020-08-12 19:19:25 +01:00
|
|
|
{ stdenv, lib, buildGoPackage, fetchFromGitHub, makeWrapper, nixosTests
|
2020-06-18 11:48:40 +01:00
|
|
|
, systemd, withSystemdSupport ? true }:
|
2018-05-04 12:21:50 +01:00
|
|
|
|
|
|
|
with stdenv.lib;
|
2018-01-26 17:39:25 +00:00
|
|
|
|
|
|
|
buildGoPackage rec {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "postfix_exporter";
|
2018-05-04 12:21:50 +01:00
|
|
|
version = "0.1.2";
|
2018-01-26 17:39:25 +00:00
|
|
|
|
|
|
|
goPackagePath = "github.com/kumina/postfix_exporter";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "kumina";
|
|
|
|
repo = "postfix_exporter";
|
2018-03-20 13:58:34 +00:00
|
|
|
rev = version;
|
2018-05-04 12:21:50 +01:00
|
|
|
sha256 = "1b9ib3scxni6hlw55wv6f0z1xfn27l0p29as24f71rs70pyzy4hm";
|
2018-01-26 17:39:25 +00:00
|
|
|
};
|
|
|
|
|
2018-05-04 12:21:50 +01:00
|
|
|
nativeBuildInputs = optional withSystemdSupport makeWrapper;
|
|
|
|
buildInputs = optional withSystemdSupport systemd;
|
|
|
|
buildFlags = optional (!withSystemdSupport) "-tags nosystemd";
|
2018-03-20 13:58:34 +00:00
|
|
|
|
2018-01-26 17:39:25 +00:00
|
|
|
goDeps = ./postfix-exporter-deps.nix;
|
2018-05-04 12:21:50 +01:00
|
|
|
extraSrcs = optionals withSystemdSupport [
|
|
|
|
{
|
|
|
|
goPackagePath = "github.com/coreos/go-systemd";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "coreos";
|
|
|
|
repo = "go-systemd";
|
|
|
|
rev = "d1b7d058aa2adfc795ad17ff4aaa2bc64ec11c78";
|
|
|
|
sha256 = "1nz3v1b90hnmj2vjjwq96pr6psxlndqjyd30v9sgiwygzb7db9mv";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
goPackagePath = "github.com/coreos/pkg";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "coreos";
|
|
|
|
repo = "pkg";
|
|
|
|
rev = "97fdf19511ea361ae1c100dd393cc47f8dcfa1e1";
|
|
|
|
sha256 = "1srn87wih25l09f75483hnxsr8fc6rq3bk7w1x8125ym39p6mg21";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
2018-01-26 17:39:25 +00:00
|
|
|
|
2018-05-04 12:21:50 +01:00
|
|
|
postInstall = optionalString withSystemdSupport ''
|
2020-04-28 02:50:57 +01:00
|
|
|
wrapProgram $out/bin/postfix_exporter \
|
2020-08-12 19:19:25 +01:00
|
|
|
--prefix LD_LIBRARY_PATH : "${lib.getLib systemd}/lib"
|
2018-03-20 13:58:34 +00:00
|
|
|
'';
|
|
|
|
|
2020-06-18 11:48:40 +01:00
|
|
|
passthru.tests = { inherit (nixosTests.prometheus-exporters) postfix; };
|
|
|
|
|
2018-05-04 12:21:50 +01:00
|
|
|
meta = {
|
2018-01-26 17:39:25 +00:00
|
|
|
inherit (src.meta) homepage;
|
|
|
|
description = "A Prometheus exporter for Postfix";
|
|
|
|
license = licenses.asl20;
|
2019-08-20 18:36:05 +01:00
|
|
|
maintainers = with maintainers; [ willibutz globin ];
|
2018-01-26 17:39:25 +00:00
|
|
|
};
|
|
|
|
}
|