From 30f8fea050f3242f0e6a2072779e706b5c8ceaf1 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Thu, 24 Sep 2026 03:42:25 +0530 Subject: refactor(modules): introduce cfg local bindings and submodule option types --- modules/system/btop/default.nix | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'modules/system/btop/default.nix') 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" -- cgit v1.2.3