at 24.05-pre 77 lines 2.7 kB view raw
1{ lib, stdenv, fetchFromGitHub, makeWrapper, perlPackages, txt2man 2, monitoring-plugins 3, wmic-bin ? null }: 4 5stdenv.mkDerivation rec { 6 pname = "check-wmiplus"; 7 version = "1.65"; 8 9 # We fetch from github.com instead of the proper upstream as nix-build errors 10 # out with 406 when trying to fetch the sources 11 src = fetchFromGitHub { 12 owner = "speartail"; 13 repo = "checkwmiplus"; 14 rev = "v${version}"; 15 sha256 = "1as0iyhy4flpm37mb7lvah7rnd6ax88appjm1icwhy7iq03wi8pl"; 16 }; 17 18 patches = [ 19 ./wmiplus_fix_manpage.patch 20 ]; 21 22 propagatedBuildInputs = with perlPackages; [ 23 BHooksEndOfScope ClassDataInheritable ClassInspector ClassSingleton 24 ConfigIniFiles DateTime DateTimeLocale DateTimeTimeZone DevelStackTrace 25 EvalClosure ExceptionClass FileShareDir ModuleImplementation ModuleRuntime 26 MROCompat namespaceautoclean namespaceclean NumberFormat PackageStash 27 ParamsValidate ParamsValidationCompiler RoleTiny Specio 28 SubExporterProgressive SubIdentify TryTiny 29 ]; 30 31 nativeBuildInputs = [ makeWrapper txt2man ]; 32 33 dontConfigure = true; 34 dontBuild = true; 35 doCheck = false; # no checks 36 37 postPatch = '' 38 substituteInPlace check_wmi_plus.pl \ 39 --replace /usr/bin/wmic ${wmic-bin}/bin/wmic \ 40 --replace /etc/check_wmi_plus $out/etc/check_wmi_plus \ 41 --replace /opt/nagios/bin/plugins $out/etc/check_wmi_plus \ 42 --replace /usr/lib/nagios/plugins ${monitoring-plugins}/libexec \ 43 --replace '$base_dir/check_wmi_plus_help.pl' "$out/bin/check_wmi_plus_help.pl" 44 45 for f in *.pl ; do 46 substituteInPlace $f --replace /usr/bin/perl ${perlPackages.perl}/bin/perl 47 done 48 ''; 49 50 installPhase = '' 51 runHook preInstall 52 53 install -Dm755 -t $out/bin *.pl 54 install -Dm644 -t $out/share/doc/${pname} *.txt 55 cp -r etc $out/ 56 57 runHook postInstall 58 ''; 59 60 # 1. we need to wait until the main binary has been fixed up with proper perl paths before we can run it to generate the man page 61 # 2. txt2man returns exit code 3 even if it works, so we add the || true bit 62 postFixup = '' 63 wrapProgram $out/bin/check_wmi_plus.pl \ 64 --set PERL5LIB "${perlPackages.makePerlPath propagatedBuildInputs}" 65 66 mkdir -p $out/share/man/man1 67 $out/bin/check_wmi_plus.pl --help | txt2man -d 1970-01-01 -s 1 -t check_wmi_plus -r "Check WMI Plus ${version}" > $out/share/man/man1/check_wmi_plus.1 || true 68 gzip $out/share/man/man1/check_wmi_plus.1 69 ''; 70 71 meta = with lib; { 72 description = "A sensu/nagios plugin using WMI to query Windows hosts"; 73 homepage = "http://edcint.co.nz/checkwmiplus"; 74 license = licenses.gpl2; 75 maintainers = with maintainers; [ peterhoeg ]; 76 }; 77}