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