From a10d60826423c098b1774b7a77c696b1b9a05bab Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 6 Nov 2025 23:40:27 -0500 Subject: [PATCH] netatop: 3.1 -> 3.2.2 and fix build --- pkgs/os-specific/linux/netatop/default.nix | 41 +++++++++---------- .../linux/netatop/fix-makefile-install.patch | 23 +++++++++++ .../linux/netatop/netatop.service.patch | 7 ---- 3 files changed, 43 insertions(+), 28 deletions(-) create mode 100644 pkgs/os-specific/linux/netatop/fix-makefile-install.patch delete mode 100644 pkgs/os-specific/linux/netatop/netatop.service.patch diff --git a/pkgs/os-specific/linux/netatop/default.nix b/pkgs/os-specific/linux/netatop/default.nix index 4dc26015f0b8..a683c84567f4 100644 --- a/pkgs/os-specific/linux/netatop/default.nix +++ b/pkgs/os-specific/linux/netatop/default.nix @@ -2,6 +2,7 @@ lib, stdenv, fetchurl, + fetchpatch, kernel, kernelModuleMakeFlags, kmod, @@ -9,15 +10,17 @@ }: let - version = "3.1"; + version = "3.2.2"; in stdenv.mkDerivation { + pname = "netatop"; + inherit version; name = "netatop-${kernel.version}-${version}"; src = fetchurl { - url = "http://www.atoptool.nl/download/netatop-${version}.tar.gz"; - sha256 = "0qjw8glfdmngfvbn1w63q128vxdz2jlabw13y140ga9i5ibl6vvk"; + url = "https://www.atoptool.nl/download/netatop-${version}.tar.gz"; + hash = "sha256-UIqJd809HN1nWHoTwl46QUZHtI+S0c44/BOLWRSuo/Y="; }; nativeBuildInputs = kernel.moduleBuildDependencies; @@ -27,34 +30,30 @@ stdenv.mkDerivation { ]; hardeningDisable = [ "pic" ]; - env.NIX_CFLAGS_COMPILE = toString [ "-Wno-error=implicit-fallthrough" ]; patches = [ # fix paths in netatop.service ./fix-paths.patch - # Specify PIDFile in /run, not /var/run to silence systemd warning - ./netatop.service.patch + # fix install paths and install the .ko instead of trying to invoke dkms + ./fix-makefile-install.patch + # replace init_module as needed by Linux 6.15 and above (backwards compatible) + (fetchpatch { + url = "https://aur.archlinux.org/cgit/aur.git/plain/netatop_kernel_6.15.patch?h=netatop-dkms&id=e5da6fa4fee5499c3e437cdd34281dd2b200508f"; + hash = "sha256-JyNQNyDJQkM/hLpb/hp3Sw2tMA8XnYogduGDFqTQ3nQ="; + }) ]; preConfigure = '' patchShebangs mkversion - sed -i -e 's,^KERNDIR.*,KERNDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build,' \ - */Makefile - sed -i -e 's,/lib/modules.*extra,'$out'/lib/modules/${kernel.modDirVersion}/extra,' \ - -e s,/usr,$out, \ - -e /init.d/d \ - -e /depmod/d \ - -e s,/lib/systemd,$out/lib/systemd, \ - Makefile - kmod=${kmod} substituteAllInPlace netatop.service ''; - makeFlags = kernelModuleMakeFlags; - - preInstall = '' - mkdir -p $out/lib/systemd/system $out/bin $out/sbin $out/share/man/man{4,8} - mkdir -p $out/lib/modules/${kernel.modDirVersion}/extra - ''; + makeFlags = kernelModuleMakeFlags ++ [ + "KERNDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" + "KMODDIRVERSION=${kernel.modDirVersion}" + # netatop builds both the module and daemon at once, and the daemon needs a wrapped cc to build + # pkgs/os-specific/linux/kernel/common-flags.nix unwraps the cc for kernel build, but we need the wrapped one + "CC=${stdenv.cc}/bin/cc" + ]; meta = { description = "Network monitoring module for atop"; diff --git a/pkgs/os-specific/linux/netatop/fix-makefile-install.patch b/pkgs/os-specific/linux/netatop/fix-makefile-install.patch new file mode 100644 index 000000000000..ee998b977ee5 --- /dev/null +++ b/pkgs/os-specific/linux/netatop/fix-makefile-install.patch @@ -0,0 +1,23 @@ +diff --color -ruN netatop-3.2.2.orig/Makefile netatop-3.2.2/Makefile +--- netatop-3.2.2.orig/Makefile 2025-11-07 13:09:10.106363095 -0500 ++++ netatop-3.2.2/Makefile 2025-11-07 16:25:35.251434714 -0500 +@@ -20,14 +20,12 @@ + + + install: netatop.ko netatopd +- cd /usr/src; dkms add -m netatop -v $(CURVERS) +- dkms build -m netatop -v $(CURVERS) +- dkms install -m netatop -v $(CURVERS) ++ install -m 0644 netatop.ko -Dt $(out)/lib/modules/$(KMODDIRVERSION)/extra + # +- install netatopd -t /usr/sbin +- install -m 0644 netatop.service -t /lib/systemd/system +- install man/netatop.4 -t /usr/share/man/man4 +- install man/netatopd.8 -t /usr/share/man/man8 ++ install netatopd -Dt $(out)/sbin ++ install -m 0644 netatop.service -Dt $(out)/lib/systemd/system ++ install man/netatop.4 -Dt $(out)/share/man/man4 ++ install man/netatopd.8 -Dt $(out)/share/man/man8 + + clean: + rm -f *.o *.ko diff --git a/pkgs/os-specific/linux/netatop/netatop.service.patch b/pkgs/os-specific/linux/netatop/netatop.service.patch deleted file mode 100644 index c7c798ee06bc..000000000000 --- a/pkgs/os-specific/linux/netatop/netatop.service.patch +++ /dev/null @@ -1,7 +0,0 @@ ---- a/netatop.service -+++ b/netatop.service -@@ -11,3 +11,3 @@ - ExecStopPost=@kmod@/bin/rmmod netatop --PIDFile=/var/run/netatop.pid -+PIDFile=/run/netatop.pid - RemainAfterExit=yes