1{ lib
2, stdenv
3, fetchurl
4, zlib
5, ncurses
6, findutils
7, systemd
8, python3
9# makes the package unfree via pynvml
10, withAtopgpu ? false
11}:
12
13stdenv.mkDerivation rec {
14 pname = "atop";
15 version = "2.8.1";
16
17 src = fetchurl {
18 url = "https://www.atoptool.nl/download/atop-${version}.tar.gz";
19 sha256 = "sha256-lwBYoZt5w0RPlx+FRXKg5jiR3C1fcDf/g3VwhUzg2h4=";
20 };
21
22 nativeBuildInputs = lib.optionals withAtopgpu [
23 python3.pkgs.wrapPython
24 ];
25
26 buildInputs = [
27 zlib
28 ncurses
29 ] ++ lib.optionals withAtopgpu [
30 python3
31 ];
32
33 pythonPath = lib.optionals withAtopgpu [
34 python3.pkgs.pynvml
35 ];
36
37 makeFlags = [
38 "DESTDIR=$(out)"
39 "BINPATH=/bin"
40 "SBINPATH=/bin"
41 "MAN1PATH=/share/man/man1"
42 "MAN5PATH=/share/man/man5"
43 "MAN8PATH=/share/man/man8"
44 "SYSDPATH=/lib/systemd/system"
45 "PMPATHD=/lib/systemd/system-sleep"
46 ];
47
48 patches = [
49 # Fix paths in atop.service, atop-rotate.service, atopgpu.service, atopacct.service,
50 # and atop-pm.sh
51 ./fix-paths.patch
52 # Don't fail on missing /etc/default/atop, make sure /var/log/atop exists pre-start
53 ./atop.service.patch
54 # Specify PIDFile in /run, not /var/run to silence systemd warning
55 ./atopacct.service.patch
56 ];
57
58 preConfigure = ''
59 for f in *.{sh,service}; do
60 findutils=${findutils} systemd=${systemd} substituteAllInPlace "$f"
61 done
62
63 substituteInPlace Makefile --replace 'chown' 'true'
64 substituteInPlace Makefile --replace 'chmod 04711' 'chmod 0711'
65 '';
66
67 preInstall = ''
68 mkdir -p $out/bin
69 '';
70
71 postInstall = ''
72 # Remove extra files we don't need
73 rm -r $out/{var,etc} $out/bin/atop{sar,}-${version}
74 '' + (if withAtopgpu then ''
75 wrapPythonPrograms
76 '' else ''
77 rm $out/lib/systemd/system/atopgpu.service $out/bin/atopgpud $out/share/man/man8/atopgpud.8
78 '');
79
80 meta = with lib; {
81 platforms = platforms.linux;
82 maintainers = with maintainers; [ raskin ];
83 description = "Console system performance monitor";
84 longDescription = ''
85 Atop is an ASCII full-screen performance monitor that is capable of reporting the activity of
86 all processes (even if processes have finished during the interval), daily logging of system
87 and process activity for long-term analysis, highlighting overloaded system resources by using
88 colors, etc. At regular intervals, it shows system-level activity related to the CPU, memory,
89 swap, disks and network layers, and for every active process it shows the CPU utilization,
90 memory growth, disk utilization, priority, username, state, and exit code.
91 '';
92 license = licenses.gpl2Plus;
93 downloadPage = "http://atoptool.nl/downloadatop.php";
94 };
95}