8 # run-time dependencies
20 , dataDir ? "/var/lib/librenms", logDir ? "/var/log/librenms" }:
24 phpPackage = php82.withExtensions ({ enabled, all }: enabled ++ [ all.memcached ]);
25 in phpPackage.buildComposerProject rec {
29 src = fetchFromGitHub {
33 sha256 = "sha256-glcD9AhxkvMmGo/7/RhQFeOtvHJ4pSiEFxaAjeVrTaI=";
36 vendorHash = "sha256-s6vdGfM7Ehy1bbkB44EQaHBBvTkpVw9yxhVsc/O8dHc=";
42 (python3.withPackages (ps: with ps; [
52 nativeBuildInputs = [ makeWrapper ];
57 mv $out/share/php/librenms/* $out
60 # This broken logic leads to bad settings being persisted in the database
61 patch -p1 -d $out -i ${./broken-binary-paths.diff}
64 $out/misc/config_definitions.json \
65 --replace '"default": "/bin/ping",' '"default": "/run/wrappers/bin/ping",' \
66 --replace '"default": "fping",' '"default": "/run/wrappers/bin/fping",' \
67 --replace '"default": "fping6",' '"default": "/run/wrappers/bin/fping6",' \
68 --replace '"default": "rrdtool",' '"default": "${rrdtool}/bin/rrdtool",' \
69 --replace '"default": "snmpgetnext",' '"default": "${net-snmp}/bin/snmpgetnext",' \
70 --replace '"default": "traceroute",' '"default": "/run/wrappers/bin/traceroute",' \
71 --replace '"default": "/usr/bin/dot",' '"default": "${graphviz}/bin/dot",' \
72 --replace '"default": "/usr/bin/ipmitool",' '"default": "${ipmitool}/bin/ipmitool",' \
73 --replace '"default": "/usr/bin/mtr",' '"default": "${mtr}/bin/mtr",' \
74 --replace '"default": "/usr/bin/nfdump",' '"default": "${nfdump}/bin/nfdump",' \
75 --replace '"default": "/usr/bin/nmap",' '"default": "${nmap}/bin/nmap",' \
76 --replace '"default": "/usr/bin/sfdp",' '"default": "${graphviz}/bin/sfdp",' \
77 --replace '"default": "/usr/bin/snmpbulkwalk",' '"default": "${net-snmp}/bin/snmpbulkwalk",' \
78 --replace '"default": "/usr/bin/snmpget",' '"default": "${net-snmp}/bin/snmpget",' \
79 --replace '"default": "/usr/bin/snmptranslate",' '"default": "${net-snmp}/bin/snmptranslate",' \
80 --replace '"default": "/usr/bin/snmpwalk",' '"default": "${net-snmp}/bin/snmpwalk",' \
81 --replace '"default": "/usr/bin/virsh",' '"default": "${libvirt}/bin/virsh",' \
82 --replace '"default": "/usr/bin/whois",' '"default": "${whois}/bin/whois",' \
83 --replace '"default": "/usr/lib/nagios/plugins",' '"default": "${monitoring-plugins}/libexec",' \
84 --replace '"default": "/usr/sbin/sendmail",' '"default": "${system-sendmail}/bin/sendmail",'
86 substituteInPlace $out/LibreNMS/wrapper.py --replace '/usr/bin/env php' '${phpPackage}/bin/php'
87 substituteInPlace $out/LibreNMS/__init__.py --replace '"/usr/bin/env", "php"' '"${phpPackage}/bin/php"'
88 substituteInPlace $out/snmp-scan.py --replace '"/usr/bin/env", "php"' '"${phpPackage}/bin/php"'
90 wrapProgram $out/daily.sh --prefix PATH : ${phpPackage}/bin
92 rm -rf $out/logs $out/rrd $out/bootstrap/cache $out/storage $out/.env
93 ln -s ${logDir} $out/logs
94 ln -s ${dataDir}/config.php $out/config.php
95 ln -s ${dataDir}/.env $out/.env
96 ln -s ${dataDir}/rrd $out/rrd
97 ln -s ${dataDir}/storage $out/storage
98 ln -s ${dataDir}/cache $out/bootstrap/cache
104 phpPackage = phpPackage;
105 tests.librenms = nixosTests.librenms;
109 description = "A auto-discovering PHP/MySQL/SNMP based network monitoring";
110 homepage = "https://www.librenms.org/";
111 license = licenses.gpl3Only;
112 maintainers = teams.wdz.members;
113 platforms = platforms.linux;