aboutsummaryrefslogtreecommitdiffstats
path: root/modules/system/btop/default.nix
blob: 40f878fa7741a148d1ad27a7743a3bd5a089590e (plain)
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
# Cross-platform graphical process and system monitor
{
  config,
  pkgs,
  lib,
  ...
}:
{
  options.system.btop = {
    enable = lib.mkEnableOption "Enables btop.";
    nvidia.enable = lib.mkEnableOption "Build btop with NVIDIA GPU monitoring support (CUDA).";
    amd.enable = lib.mkEnableOption "Build btop with AMD GPU monitoring support (ROCm).";
    package = lib.mkOption {
      type = lib.types.package;
      readOnly = true;
      default = pkgs.btop.override {
        cudaSupport = config.system.btop.nvidia.enable;
        rocmSupport = config.system.btop.amd.enable;
      };
      description = "The btop package to use.";
    };
  };

  config = lib.mkMerge [
    (lib.mkIf config.system.btop.enable {
      programs.btop = {
        enable = true;
        package = config.system.btop.package;
      };
    })
    (lib.mkIf (config.system.btop.enable && config.terminal.kitty.enable) {
      xdg.desktopEntries."btop" = {
        name = "btop++";
        exec = "${lib.getExe config.terminal.kitty.package} --class btop -e ${lib.getExe config.system.btop.package}";
        icon = "btop";
        categories = [
          "System"
          "Monitor"
          "ConsoleOnly"
        ];
        comment = "Cross-platform graphical process and system monitor";
        terminal = false;
        type = "Application";
      };
    })
  ];
}