about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/monitoring/nagios/default.nix
blob: 442eed82478e1ea4532a94220b76d3a739d58390 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{ lib
, stdenv
, fetchFromGitHub
, perl
, php
, gd
, libpng
, openssl
, zlib
, unzip
, nixosTests
, nix-update-script
}:

stdenv.mkDerivation rec {
  pname = "nagios";
  version = "4.5.0";

  src = fetchFromGitHub {
    owner = "NagiosEnterprises";
    repo = "nagioscore";
    rev = "refs/tags/nagios-${version}";
    hash = "sha256-km0vB/bopysS7eejDFDKaonXzTzBonIqiw1T+C2lKiQ=";
  };

  patches = [ ./nagios.patch ];
  nativeBuildInputs = [ unzip ];

  buildInputs = [
    php
    perl
    gd
    libpng
    openssl
    zlib
  ];

  configureFlags = [
    "--localstatedir=/var/lib/nagios"
    "--with-ssl=${openssl.dev}"
    "--with-ssl-inc=${openssl.dev}/include"
    "--with-ssl-lib=${lib.getLib openssl}/lib"
  ];

  buildFlags = [ "all" ];

  # Do not create /var directories
  preInstall = ''
    substituteInPlace Makefile --replace '$(MAKE) install-basic' ""
  '';
  installTargets = "install install-config";
  postInstall = ''
    # don't make default files use hardcoded paths to commands
    sed -i 's@command_line *[^ ]*/\([^/]*\) @command_line \1 @'  $out/etc/objects/commands.cfg
    sed -i 's@/usr/bin/@@g' $out/etc/objects/commands.cfg
    sed -i 's@/bin/@@g' $out/etc/objects/commands.cfg
  '';

  passthru = {
    tests = {
      inherit (nixosTests) nagios;
    };
    updateScript = nix-update-script {
      extraArgs = [ "--version-regex" "nagios-(.*)" ];
    };
  };

  meta = {
    description = "A host, service and network monitoring program";
    homepage = "https://www.nagios.org/";
    changelog = "https://github.com/NagiosEnterprises/nagioscore/blob/nagios-${version}/Changelog";
    license = lib.licenses.gpl2;
    platforms = lib.platforms.linux;
    mainProgram = "nagios";
    maintainers = with lib.maintainers; [ immae thoughtpolice relrod anthonyroussel ];
  };
}