From 552efeba59d5e7b75046161a91679d273eda1e8a Mon Sep 17 00:00:00 2001 From: Dominik Honnef Date: Sat, 20 May 2023 14:46:37 +0200 Subject: [PATCH] nut: actually update to 2.8.0 The previous attempt at updating nut forgot to change the fod hash for the source code. Actually updating to 2.8.0 required some changes to dependencies and the patch for nut-scanner. We no longer need --without-hal because HAL support was removed as far back as verison 2.7.2. --- pkgs/applications/misc/nut/default.nix | 49 ++++++++++++++----- .../misc/nut/hardcode-paths.patch | 17 ++++--- 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/pkgs/applications/misc/nut/default.nix b/pkgs/applications/misc/nut/default.nix index 45db4d479775..0afe4bf18c1e 100644 --- a/pkgs/applications/misc/nut/default.nix +++ b/pkgs/applications/misc/nut/default.nix @@ -1,5 +1,21 @@ -{ lib, stdenv, fetchurl, substituteAll, pkg-config, neon, libusb-compat-0_1, openssl, udev, avahi, freeipmi -, libtool, makeWrapper, autoreconfHook, fetchpatch +{ lib +, stdenv +, autoreconfHook +, avahi +, coreutils +, fetchurl +, freeipmi +, i2c-tools +, libmodbus +, libtool +, libusb-compat-0_1 +, makeWrapper +, neon +, openssl +, pkg-config +, substituteAll +, systemd +, udev }: stdenv.mkDerivation rec { @@ -8,25 +24,21 @@ stdenv.mkDerivation rec { src = fetchurl { url = "https://networkupstools.org/source/${lib.versions.majorMinor version}/${pname}-${version}.tar.gz"; - sha256 = "19r5dm07sfz495ckcgbfy0pasx0zy3faa0q7bih69lsjij8q43lq"; + sha256 = "sha256-w+WnCNp5e3xwtlPTexIGoAD8tQO4VRn+TN9jU/eSv+U="; }; patches = [ - (fetchpatch { - # Fix build with openssl >= 1.1.0 - url = "https://github.com/networkupstools/nut/commit/612c05efb3c3b243da603a3a050993281888b6e3.patch"; - sha256 = "0jdbii1z5sqyv24286j5px65j7b3gp8zk3ahbph83pig6g46m3hs"; - }) (substituteAll { src = ./hardcode-paths.patch; avahi = "${avahi}/lib"; freeipmi = "${freeipmi}/lib"; libusb = "${libusb-compat-0_1}/lib"; neon = "${neon}/lib"; + libmodbus = "${libmodbus}/lib"; }) ]; - buildInputs = [ neon libusb-compat-0_1 openssl udev avahi freeipmi ]; + buildInputs = [ neon libusb-compat-0_1 openssl udev avahi freeipmi libmodbus i2c-tools ]; nativeBuildInputs = [ autoreconfHook libtool pkg-config makeWrapper ]; @@ -36,14 +48,27 @@ stdenv.mkDerivation rec { "--without-snmp" # Until we have it ... "--without-powerman" # Until we have it ... "--without-cgi" - "--without-hal" - "--with-systemdsystemunitdir=$(out)/etc/systemd/system" + "--with-systemdsystemunitdir=$(out)/lib/systemd/system" + "--with-systemdshutdowndir=$(out)/lib/systemd/system-shutdown" + "--with-systemdtmpfilesdir=$(out)/lib/tmpfiles.d" "--with-udev-dir=$(out)/etc/udev" ]; enableParallelBuilding = true; - env.NIX_CFLAGS_COMPILE = toString [ "-std=c++14" ]; + postInstall = '' + substituteInPlace $out/lib/systemd/system-shutdown/nutshutdown \ + --replace /bin/sleep "${coreutils}/bin/sleep" \ + --replace /bin/systemctl "${systemd}/bin/systemctl" + + for file in system/{nut-monitor.service,nut-driver-enumerator.service,nut-server.service,nut-driver@.service} system-shutdown/nutshutdown; do + substituteInPlace $out/lib/systemd/$file \ + --replace "$out/etc/nut.conf" "/etc/nut.conf" + done + + # we don't need init.d scripts + rm -r $out/share/solaris-init + ''; meta = with lib; { description = "Network UPS Tools"; diff --git a/pkgs/applications/misc/nut/hardcode-paths.patch b/pkgs/applications/misc/nut/hardcode-paths.patch index db6d68471ce5..5116fb438e53 100644 --- a/pkgs/applications/misc/nut/hardcode-paths.patch +++ b/pkgs/applications/misc/nut/hardcode-paths.patch @@ -1,13 +1,14 @@ ---- a/tools/nut-scanner/nutscan-init.c -+++ b/tools/nut-scanner/nutscan-init.c -@@ -44,6 +44,10 @@ int nutscan_load_upsclient_library(const char *libname_path); - - /* FIXME: would be good to get more from /etc/ld.so.conf[.d] */ - char * search_paths[] = { +--- a/common/common.c ++++ b/common/common.c +@@ -991,6 +991,11 @@ ssize_t select_write(const int fd, const void *buf, const size_t buflen, const t + * communications media and/or vendor protocol. + */ + static const char * search_paths[] = { + "@avahi@", + "@freeipmi@", + "@libusb@", + "@neon@", ++ "@libmodbus@", + /* Use the library path (and bitness) provided during ./configure first */ LIBDIR, - "/usr/lib64", - "/lib64", + "/usr"LIBDIR,