@@ -1,8 +1,11 @@
1−{ stdenv, buildGoPackage, fetchFromGitHub, systemd, makeWrapper }:
1+{ stdenv, buildGoPackage, fetchFromGitHub, systemd, makeWrapper
2+, withSystemdSupport ? true }:
3+
4+with stdenv.lib;
25
36buildGoPackage rec {
47 name = "postfix_exporter-${version}";
5− version = "0.1.1";
8+ version = "0.1.2";
69
710 goPackagePath = "github.com/kumina/postfix_exporter";
811
@@ -10,20 +13,41 @@ buildGoPackage rec {
1013 owner = "kumina";
1114 repo = "postfix_exporter";
1215 rev = version;
13− sha256 = "1p2j66jzzgyv2w832pw57g02vrac6ldrblqllgwyy0i8krb3ibyz";
16+ sha256 = "1b9ib3scxni6hlw55wv6f0z1xfn27l0p29as24f71rs70pyzy4hm";
1417 };
1518
16− nativeBuildInputs = [ makeWrapper ];
17− buildInputs = [ systemd ];
19+ nativeBuildInputs = optional withSystemdSupport makeWrapper;
20+ buildInputs = optional withSystemdSupport systemd;
21+ buildFlags = optional (!withSystemdSupport) "-tags nosystemd";
1822
1923 goDeps = ./postfix-exporter-deps.nix;
24+ extraSrcs = optionals withSystemdSupport [
25+ {
26+ goPackagePath = "github.com/coreos/go-systemd";
27+ src = fetchFromGitHub {
28+ owner = "coreos";
29+ repo = "go-systemd";
30+ rev = "d1b7d058aa2adfc795ad17ff4aaa2bc64ec11c78";
31+ sha256 = "1nz3v1b90hnmj2vjjwq96pr6psxlndqjyd30v9sgiwygzb7db9mv";
32+ };
33+ }
34+ {
35+ goPackagePath = "github.com/coreos/pkg";
36+ src = fetchFromGitHub {
37+ owner = "coreos";
38+ repo = "pkg";
39+ rev = "97fdf19511ea361ae1c100dd393cc47f8dcfa1e1";
40+ sha256 = "1srn87wih25l09f75483hnxsr8fc6rq3bk7w1x8125ym39p6mg21";
41+ };
42+ }
43+ ];
2044
21− postInstall = ''
45+ postInstall = optionalString withSystemdSupport ''
2246 wrapProgram $bin/bin/postfix_exporter \
2347 --prefix LD_LIBRARY_PATH : "${systemd.lib}/lib"
2448 '';
2549
26− meta = with stdenv.lib; {
50+ meta = {
2751 inherit (src.meta) homepage;
2852 description = "A Prometheus exporter for Postfix";
2953 license = licenses.asl20;