summary refs log tree commit diff
path: root/pkgs/applications/misc/nut/default.nix
diff options
context:
space:
mode:
authorDominik Honnef <dominik@honnef.co>2023-05-20 14:46:37 +0200
committerSandro Jäckel <sandro.jaeckel@gmail.com>2023-07-09 22:59:29 +0200
commit552efeba59d5e7b75046161a91679d273eda1e8a (patch)
treeac2db51d0a50af08a9c522e92906a7c4e786b92c /pkgs/applications/misc/nut/default.nix
parent552a15429972a9c74374eba5ba1d4b3eb540537e (diff)
downloadnixpkgs-552efeba59d5e7b75046161a91679d273eda1e8a.tar
nixpkgs-552efeba59d5e7b75046161a91679d273eda1e8a.tar.gz
nixpkgs-552efeba59d5e7b75046161a91679d273eda1e8a.tar.bz2
nixpkgs-552efeba59d5e7b75046161a91679d273eda1e8a.tar.lz
nixpkgs-552efeba59d5e7b75046161a91679d273eda1e8a.tar.xz
nixpkgs-552efeba59d5e7b75046161a91679d273eda1e8a.tar.zst
nixpkgs-552efeba59d5e7b75046161a91679d273eda1e8a.zip
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.
Diffstat (limited to 'pkgs/applications/misc/nut/default.nix')
-rw-r--r--pkgs/applications/misc/nut/default.nix49
1 files changed, 37 insertions, 12 deletions
diff --git a/pkgs/applications/misc/nut/default.nix b/pkgs/applications/misc/nut/default.nix
index 45db4d47977..0afe4bf18c1 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";