9 # run-time dependencies
21 dataDir ? "/var/lib/librenms",
22 logDir ? "/var/log/librenms",
26 phpPackage = php82.withExtensions ({ enabled, all }: enabled ++ [ all.memcached ]);
28 phpPackage.buildComposerProject rec {
32 src = fetchFromGitHub {
36 sha256 = "sha256-/0mc4wTx9WDxgDxqq+Kut8uX/Yr+bxqZ1BeJvmFDxG8=";
39 vendorHash = "sha256-DNiTSXt/1Qr67BdlTu3ccP4Whw5pyybeFJ045c/e8Dc=";
56 (python3.withPackages (
69 nativeBuildInputs = [ makeWrapper ];
74 mv $out/share/php/librenms/* $out
77 # This broken logic leads to bad settings being persisted in the database
78 patch -p1 -d $out -i ${./broken-binary-paths.diff}
81 $out/misc/config_definitions.json \
82 --replace '"default": "/bin/ping",' '"default": "/run/wrappers/bin/ping",' \
83 --replace '"default": "fping",' '"default": "/run/wrappers/bin/fping",' \
84 --replace '"default": "fping6",' '"default": "/run/wrappers/bin/fping6",' \
85 --replace '"default": "rrdtool",' '"default": "${rrdtool}/bin/rrdtool",' \
86 --replace '"default": "snmpgetnext",' '"default": "${net-snmp}/bin/snmpgetnext",' \
87 --replace '"default": "traceroute",' '"default": "/run/wrappers/bin/traceroute",' \
88 --replace '"default": "/usr/bin/dot",' '"default": "${graphviz}/bin/dot",' \
89 --replace '"default": "/usr/bin/ipmitool",' '"default": "${ipmitool}/bin/ipmitool",' \
90 --replace '"default": "/usr/bin/mtr",' '"default": "${mtr}/bin/mtr",' \
91 --replace '"default": "/usr/bin/nfdump",' '"default": "${nfdump}/bin/nfdump",' \
92 --replace '"default": "/usr/bin/nmap",' '"default": "${nmap}/bin/nmap",' \
93 --replace '"default": "/usr/bin/sfdp",' '"default": "${graphviz}/bin/sfdp",' \
94 --replace '"default": "/usr/bin/snmpbulkwalk",' '"default": "${net-snmp}/bin/snmpbulkwalk",' \
95 --replace '"default": "/usr/bin/snmpget",' '"default": "${net-snmp}/bin/snmpget",' \
96 --replace '"default": "/usr/bin/snmptranslate",' '"default": "${net-snmp}/bin/snmptranslate",' \
97 --replace '"default": "/usr/bin/snmpwalk",' '"default": "${net-snmp}/bin/snmpwalk",' \
98 --replace '"default": "/usr/bin/virsh",' '"default": "${libvirt}/bin/virsh",' \
99 --replace '"default": "/usr/bin/whois",' '"default": "${whois}/bin/whois",' \
100 --replace '"default": "/usr/lib/nagios/plugins",' '"default": "${monitoring-plugins}/bin",' \
101 --replace '"default": "/usr/sbin/sendmail",' '"default": "${system-sendmail}/bin/sendmail",'
103 substituteInPlace $out/LibreNMS/wrapper.py --replace-fail '/usr/bin/env php' '${phpPackage}/bin/php'
104 substituteInPlace $out/LibreNMS/__init__.py --replace-fail '"/usr/bin/env", "php"' '"${phpPackage}/bin/php"'
105 substituteInPlace $out/snmp-scan.py --replace-fail '"/usr/bin/env", "php"' '"${phpPackage}/bin/php"'
107 substituteInPlace $out/lnms --replace-fail '\App\Checks::runningUser();' '//\App\Checks::runningUser(); //removed as nix forces ownership to root'
109 wrapProgram $out/daily.sh --prefix PATH : ${phpPackage}/bin
111 php $out/artisan vue-i18n:generate --multi-locales --format=umd
113 rm -rf $out/logs $out/rrd $out/bootstrap/cache $out/storage $out/.env
114 ln -s ${logDir} $out/logs
115 ln -s ${dataDir}/config.php $out/config.php
116 ln -s ${dataDir}/.env $out/.env
117 ln -s ${dataDir}/rrd $out/rrd
118 ln -s ${dataDir}/storage $out/storage
119 ln -s ${dataDir}/cache $out/bootstrap/cache
125 phpPackage = phpPackage;
126 tests.librenms = nixosTests.librenms;
130 description = "Auto-discovering PHP/MySQL/SNMP based network monitoring";
131 homepage = "https://www.librenms.org/";
132 license = licenses.gpl3Only;
133 maintainers = with maintainers; [ netali ] ++ teams.wdz.members;
134 platforms = platforms.linux;