mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
netatop: 3.1 -> 3.2.2 and fix build (#459364)
This commit is contained in:
@@ -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";
|
||||
|
||||
23
pkgs/os-specific/linux/netatop/fix-makefile-install.patch
Normal file
23
pkgs/os-specific/linux/netatop/fix-makefile-install.patch
Normal file
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user