about summary refs log tree commit diff
path: root/pkgs/by-name/gp/gpustat/package.nix
blob: d98ff336ed399883d9fe7ea720dc1d820fec22b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{ lib
, fetchFromGitHub
, rustPlatform
, pkg-config
, fontconfig
, libGL
, libX11
, libXcursor
, libXi
, libXrandr
, cmake
, libxkbcommon
, wayland
, makeWrapper
}:

rustPlatform.buildRustPackage rec {
  pname = "gpustat";
  version = "0.1.5";

  src = fetchFromGitHub {
    owner = "arduano";
    repo = "gpustat";
    rev = "v${version}";
    sha256 = "sha256-M9P/qfw/tp9ogkNOE3b2fD2rGFnii1/VwmqJHqXb7Mg=";
  };

  cargoSha256 = "sha256-po/pEMZEtySZnz7l2FI7Wqbmp2CiWBijchKGkqlIMPU=";

  nativeBuildInputs = [
    cmake
    makeWrapper
    pkg-config
  ];

  buildInputs = [
    fontconfig
    libGL
    libX11
    libXcursor
    libXi
    libXrandr
    libxkbcommon
    wayland
  ];

  postInstall = ''
    mkdir -p $out/share/applications $out/share/pixmaps

    cp assets/gpustat.desktop $out/share/applications
    cp assets/gpustat_icon_* $out/share/pixmaps
  '';

  # Wrap the program in a script that sets the LD_LIBRARY_PATH environment variable
  # so that it can find the shared libraries it depends on. This is currently a
  # requirement for running Rust programs that depend on `egui` within a Nix environment.
  # https://github.com/emilk/egui/issues/2486
  postFixup = ''
    wrapProgram $out/bin/gpustat \
      --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath buildInputs}:/run/opengl-driver/lib"
  '';

  meta = with lib; {
    description = "Simple utility for viewing GPU utilization";
    homepage = "https://github.com/arduano/gpustat";
    license = licenses.asl20;
    maintainers = with maintainers; [ arduano ];
    mainProgram = "gpustat";
    platforms = platforms.linux;
  };
}