25 stdenv.mkDerivation rec {
30 url = "https://networkupstools.org/source/${lib.versions.majorMinor version}/${pname}-${version}.tar.gz";
31 sha256 = "sha256-5LSwy+fdObqQl75/fXh7sv/74132Tf9Ttf45PWWcWX0=";
35 # This patch injects a default value for NUT_CONFPATH into the nutshutdown script
36 # since the way we build the package results in the binaries being hardcoded to check
37 # $out/etc/ups.conf instead of /etc/nut/ups.conf (where the module places the file).
38 # We also cannot use `--sysconfdir=/etc/nut` since that results in the install phase
39 # trying to install directly into /etc/nut which predictably fails
40 ./nutshutdown-conf-default.patch
43 src = ./hardcode-paths.patch;
44 avahi = "${avahi}/lib";
45 freeipmi = "${freeipmi}/lib";
46 libgpiod = "${libgpiod_1}/lib";
47 libusb = "${libusb1}/lib";
49 libmodbus = "${libmodbus}/lib";
50 netsnmp = "${net-snmp.lib}/lib";
54 buildInputs = [ neon libusb1 openssl udev avahi freeipmi libgpiod_1 libmodbus libtool i2c-tools net-snmp gd ];
56 nativeBuildInputs = [ autoreconfHook pkg-config makeWrapper ];
61 "--without-powerman" # Until we have it ...
62 "--with-systemdsystemunitdir=$(out)/lib/systemd/system"
63 "--with-systemdshutdowndir=$(out)/lib/systemd/system-shutdown"
64 "--with-systemdtmpfilesdir=$(out)/lib/tmpfiles.d"
65 "--with-udev-dir=$(out)/etc/udev"
68 enableParallelBuilding = true;
70 # Add `cgi-bin` to the default list to avoid pulling in whole
71 # of `gcc` into build closure.
72 stripDebugList = [ "cgi-bin" "lib" "lib32" "lib64" "libexec" "bin" "sbin" ];
75 substituteInPlace $out/lib/systemd/system-shutdown/nutshutdown \
76 --replace /bin/sed "${gnused}/bin/sed" \
77 --replace /bin/sleep "${coreutils}/bin/sleep" \
78 --replace /bin/systemctl "${systemd}/bin/systemctl"
80 for file in system/{nut-monitor.service,nut-driver-enumerator.service,nut-server.service,nut-driver@.service} system-shutdown/nutshutdown; do
81 substituteInPlace $out/lib/systemd/$file \
82 --replace "$out/etc/nut.conf" "/etc/nut/nut.conf"
85 substituteInPlace $out/lib/systemd/system/nut-driver-enumerator.path \
86 --replace "$out/etc/ups.conf" "/etc/nut/ups.conf"
88 # Suspicious/overly broad rule, remove it until we know better
89 rm $out/etc/udev/rules.d/52-nut-ipmipsu.rules
93 description = "Network UPS Tools";
95 Network UPS Tools is a collection of programs which provide a common
96 interface for monitoring and administering UPS, PDU and SCD hardware.
97 It uses a layered approach to connect all of the parts.
99 homepage = "https://networkupstools.org/";
100 platforms = platforms.linux;
101 maintainers = [ maintainers.pierron ];
102 license = with licenses; [ gpl1Plus gpl2Plus gpl3Plus ];