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