biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / servers / monitoring / munin / default.nix
blobc86d08cd68714d4ada526927710f1b9d8c98e001
1 { lib, stdenv, fetchFromGitHub, makeWrapper, which, coreutils, rrdtool, perlPackages
2 , python3, ruby, jre8, nettools, bc
3 }:
5 stdenv.mkDerivation rec {
6   version = "2.0.75";
7   pname = "munin";
9   src = fetchFromGitHub {
10     owner = "munin-monitoring";
11     repo = "munin";
12     rev = version;
13     sha256 = "sha256-fxjF2CV5SoUTirusGQBpbNu9MYKU5yx+DHS2h0NJoic=";
14   };
16   nativeBuildInputs = [
17     makeWrapper
18   ];
20   buildInputs = [
21     which
22     coreutils
23     rrdtool
24     nettools
25     perlPackages.perl
26     perlPackages.ModuleBuild
27     perlPackages.HTMLTemplate
28     perlPackages.NetCIDR
29     perlPackages.NetSSLeay
30     perlPackages.NetServer
31     perlPackages.LogLog4perl
32     perlPackages.IOSocketINET6
33     perlPackages.Socket6
34     perlPackages.URI
35     perlPackages.DBFile
36     perlPackages.TimeDate
37     perlPackages.FileCopyRecursive
38     perlPackages.FCGI
39     perlPackages.NetSNMP
40     perlPackages.NetServer
41     perlPackages.ListMoreUtils
42     perlPackages.LWP
43     perlPackages.DBDPg
44     python3
45     ruby
46     jre8
47     # tests
48     perlPackages.TestLongString
49     perlPackages.TestDifferences
50     perlPackages.TestDeep
51     perlPackages.TestMockModule
52     perlPackages.TestMockObject
53     perlPackages.FileSlurp
54     perlPackages.IOStringy
55   ];
57   # needs to find a local perl module during build
58   env.PERL_USE_UNSAFE_INC = "1";
60   # TODO: tests are failing https://munin-monitoring.org/ticket/1390#comment:1
61   # NOTE: important, test command always exits with 0, think of a way to abort the build once tests pass
62   doCheck = false;
64   checkPhase = ''
65    export PERL5LIB="$PERL5LIB:${rrdtool}/${perlPackages.perl.libPrefix}"
66    LC_ALL=C make -j1 test
67   '';
69   patches = [
70     # https://rt.cpan.org/Public/Bug/Display.html?id=75112
71     ./dont_preserve_source_dir_permissions.patch
73     # https://github.com/munin-monitoring/munin/pull/134
74     ./adding_servicedir_munin-node.patch
76     ./adding_sconfdir_munin-node.patch
77     ./preserve_environment.patch
78   ];
80   preBuild = ''
81     echo "${version}" > RELEASE
82     substituteInPlace "Makefile" \
83       --replace "/bin/pwd" "pwd" \
84       --replace "HTMLOld.3pm" "HTMLOld.3"
86     # munin checks at build time if user/group exists, unpure
87     sed -i '/CHECKUSER/d' Makefile
88     sed -i '/CHOWN/d' Makefile
89     sed -i '/CHECKGROUP/d' Makefile
91     # munin hardcodes PATH, we need it to obey $PATH
92     sed -i '/ENV{PATH}/d' node/lib/Munin/Node/Service.pm
93   '';
95   # Disable parallel build, errors:
96   #  Can't locate Munin/Common/Defaults.pm in @INC ...
97   enableParallelBuilding = false;
99   # DESTDIR shouldn't be needed (and shouldn't have worked), but munin
100   # developers have forgotten to use PREFIX everywhere, so we use DESTDIR to
101   # ensure that everything is installed in $out.
102   makeFlags = [
103     "PREFIX=$(out)"
104     "DESTDIR=$(out)"
105     "PERLLIB=$(out)/${perlPackages.perl.libPrefix}"
106     "PERL=${perlPackages.perl.outPath}/bin/perl"
107     "PYTHON=${python3.interpreter}"
108     "RUBY=${ruby.outPath}/bin/ruby"
109     "JAVARUN=${jre8.outPath}/bin/java"
110     "PLUGINUSER=munin"
111   ];
113   postFixup = ''
114     echo "Removing references to /usr/{bin,sbin}/ from munin plugins..."
115     find "$out/lib/plugins" -type f -print0 | xargs -0 -L1 \
116         sed -i -e "s|/usr/bin/||g" -e "s|/usr/sbin/||g" -e "s|\<bc\>|${bc}/bin/bc|g"
118     if test -e $out/nix-support/propagated-build-inputs; then
119         ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages
120     fi
122     for file in "$out"/bin/munindoc "$out"/sbin/munin-* "$out"/lib/munin-* "$out"/www/cgi/*; do
123         # don't wrap .jar files
124         case "$file" in
125             *.jar) continue;;
126         esac
127         wrapProgram "$file" \
128           --set PERL5LIB "$out/${perlPackages.perl.libPrefix}:${with perlPackages; makePerlPath [
129                 LogLog4perl IOSocketINET6 Socket6 URI DBFile TimeDate
130                 HTMLTemplate FileCopyRecursive FCGI NetCIDR NetSNMP NetServer
131                 ListMoreUtils DBDPg LWP rrdtool
132                 ]}"
133     done
134   '';
136   meta = with lib; {
137     description = "Networked resource monitoring tool";
138     longDescription = ''
139       Munin is a monitoring tool that surveys all your computers and remembers
140       what it saw. It presents all the information in graphs through a web
141       interface. Munin can help analyze resource trends and 'what just happened
142       to kill our performance?' problems.
143     '';
144     homepage = "https://munin-monitoring.org/";
145     license = licenses.gpl2;
146     maintainers = [ maintainers.bjornfor ];
147     platforms = platforms.linux;
148   };