diff options
| author | Arpit Chakladar <arpitchakladar@gmail.com> | 2026-09-24 03:42:25 +0530 |
|---|---|---|
| committer | Arpit Chakladar <arpitchakladar@gmail.com> | 2026-09-24 03:42:25 +0530 |
| commit | 30f8fea050f3242f0e6a2072779e706b5c8ceaf1 (patch) | |
| tree | a02b517bd112d4e91fab15166a4866bff252c2d3 /modules/system/btop | |
| parent | ad96214c9ab94bce925000a6059e3c68e2ff6a22 (diff) | |
| download | home-manager-config-30f8fea050f3242f0e6a2072779e706b5c8ceaf1.tar.gz home-manager-config-30f8fea050f3242f0e6a2072779e706b5c8ceaf1.zip | |
refactor(modules): introduce cfg local bindings and submodule option types
Diffstat (limited to 'modules/system/btop')
| -rw-r--r-- | modules/system/btop/default.nix | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/modules/system/btop/default.nix b/modules/system/btop/default.nix index 4f84036..453bafb 100644 --- a/modules/system/btop/default.nix +++ b/modules/system/btop/default.nix @@ -1,39 +1,58 @@ # Cross-platform graphical process and system monitor { config, - pkgs, lib, + pkgs, ... }: +let + cfg = config.system.btop; +in { imports = [ ./assertions.nix ]; 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)."; + nvidia = lib.mkOption { + type = lib.types.submodule { + options = { + enable = lib.mkEnableOption "Build btop with NVIDIA GPU monitoring support (CUDA)."; + }; + }; + default = { }; + description = "NVIDIA GPU monitoring configuration."; + }; + amd = lib.mkOption { + type = lib.types.submodule { + options = { + enable = lib.mkEnableOption "Build btop with AMD GPU monitoring support (ROCm)."; + }; + }; + default = { }; + description = "AMD GPU monitoring configuration."; + }; 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; + cudaSupport = cfg.nvidia.enable; + rocmSupport = cfg.amd.enable; }; description = "The btop package to use."; }; }; config = lib.mkMerge [ - (lib.mkIf config.system.btop.enable { + (lib.mkIf cfg.enable { programs.btop = { enable = true; - package = config.system.btop.package; + package = cfg.package; }; }) - (lib.mkIf (config.system.btop.enable && config.terminal.kitty.enable) { + (lib.mkIf (cfg.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}"; + exec = "${lib.getExe config.terminal.kitty.package} --class btop -e ${lib.getExe cfg.package}"; icon = "btop"; categories = [ "System" |
