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/terminal | |
| 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/terminal')
| -rw-r--r-- | modules/terminal/bat/default.nix | 3 | ||||
| -rw-r--r-- | modules/terminal/fzf/default.nix | 75 | ||||
| -rw-r--r-- | modules/terminal/kitty/default.nix | 6 | ||||
| -rw-r--r-- | modules/terminal/less/default.nix | 12 | ||||
| -rw-r--r-- | modules/terminal/starship/default.nix | 96 | ||||
| -rw-r--r-- | modules/terminal/tmux/default.nix | 6 | ||||
| -rw-r--r-- | modules/terminal/zsh/default.nix | 34 |
7 files changed, 128 insertions, 104 deletions
diff --git a/modules/terminal/bat/default.nix b/modules/terminal/bat/default.nix index 69045bc..735f08f 100644 --- a/modules/terminal/bat/default.nix +++ b/modules/terminal/bat/default.nix @@ -6,6 +6,7 @@ ... }: let + cfg = config.terminal.bat; base16Colors = import ../../colors/base16 { inherit config lib pkgs; }; in { @@ -19,7 +20,7 @@ in }; }; - config = lib.mkIf config.terminal.bat.enable { + config = lib.mkIf cfg.enable { programs.bat = { enable = true; config = { diff --git a/modules/terminal/fzf/default.nix b/modules/terminal/fzf/default.nix index a7cc2f5..080e6a2 100644 --- a/modules/terminal/fzf/default.nix +++ b/modules/terminal/fzf/default.nix @@ -6,7 +6,12 @@ ... }: let + cfg = config.terminal.fzf; base16Colors = import ../../colors/base16 { inherit config lib pkgs; }; + + shellIntegration = '' + ${if config.terminal.zsh.enable then "eval \"$(fzf --zsh)\"" else "eval \"$(fzf --bash)\""} + ''; in { imports = [ ./assertions.nix ]; @@ -21,48 +26,42 @@ in }; }; - config = - let - shellIntegration = '' - ${if config.terminal.zsh.enable then "eval \"$(fzf --zsh)\"" else "eval \"$(fzf --bash)\""} - ''; - in - lib.mkIf config.terminal.fzf.enable { - programs.fzf = { - enable = true; - defaultOptions = [ - "--height 100%" - "--layout=reverse" - "--pointer=' '" - "--header=' '" - "--prompt=' '" - "--marker='✓ '" - "--border=none" - "--cycle" - "--no-info" - "--margin='1,2'" - ]; + config = lib.mkIf cfg.enable { + programs.fzf = { + enable = true; + defaultOptions = [ + "--height 100%" + "--layout=reverse" + "--pointer=' '" + "--header=' '" + "--prompt=' '" + "--marker='✓ '" + "--border=none" + "--cycle" + "--no-info" + "--margin='1,2'" + ]; - colors = with base16Colors.colorsWithHashPrefix; { - fg = base05; - bg = "-1"; - hl = base0D; + colors = with base16Colors.colorsWithHashPrefix; { + fg = base05; + bg = "-1"; + hl = base0D; - "fg+" = base07; - "bg+" = "-1"; - "hl+" = base0D; + "fg+" = base07; + "bg+" = "-1"; + "hl+" = base0D; - gutter = "-1"; + gutter = "-1"; - info = base0B; - border = base03; - prompt = base0A; - pointer = base0F; - marker = base0C; - spinner = base0C; - }; + info = base0B; + border = base03; + prompt = base0A; + pointer = base0F; + marker = base0C; + spinner = base0C; }; - - programs.zsh.initContent = lib.mkIf config.terminal.zsh.enable (lib.mkAfter shellIntegration); }; + + programs.zsh.initContent = lib.mkIf config.terminal.zsh.enable (lib.mkAfter shellIntegration); + }; } diff --git a/modules/terminal/kitty/default.nix b/modules/terminal/kitty/default.nix index e7a5fbb..7e4c701 100644 --- a/modules/terminal/kitty/default.nix +++ b/modules/terminal/kitty/default.nix @@ -2,8 +2,12 @@ { config, lib, + pkgs, ... }: +let + cfg = config.terminal.kitty; +in { imports = [ ./colors.nix @@ -20,7 +24,7 @@ }; }; - config = lib.mkIf config.terminal.kitty.enable { + config = lib.mkIf cfg.enable { xdg.mimeApps.defaultApplications = { "x-scheme-handler/terminal" = "kitty.desktop"; }; diff --git a/modules/terminal/less/default.nix b/modules/terminal/less/default.nix index 66ddce9..d8b0993 100644 --- a/modules/terminal/less/default.nix +++ b/modules/terminal/less/default.nix @@ -1,5 +1,13 @@ # Terminal pager -{ config, lib, ... }: +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.terminal.less; +in { options.terminal.less = { enable = lib.mkEnableOption "Enables less."; @@ -11,7 +19,7 @@ }; }; - config = lib.mkIf config.terminal.less.enable { + config = lib.mkIf cfg.enable { programs.less = { enable = true; options = [ diff --git a/modules/terminal/starship/default.nix b/modules/terminal/starship/default.nix index 6aa83d6..3a7d8af 100644 --- a/modules/terminal/starship/default.nix +++ b/modules/terminal/starship/default.nix @@ -1,5 +1,15 @@ # Minimal, blazing-fast shell prompt -{ config, lib, ... }: +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.terminal.starship; + + mkSegment = content: ''[┄\[](red)[${content}]($style)[\]](red)''; +in { options.terminal.starship = { enable = lib.mkEnableOption "Enables starship."; @@ -11,63 +21,59 @@ }; }; - config = lib.mkIf config.terminal.starship.enable { + config = lib.mkIf cfg.enable { programs.starship = { enable = true; enableZshIntegration = config.terminal.zsh.enable; - settings = - let - mkSegment = content: ''[┄\[](red)[${content}]($style)[\]](red)''; - in - { - add_newline = true; + settings = { + add_newline = true; - format = ''''\n[╭─\[](red)$username[@](red)$hostname[\]](red)$directory$git_branch$git_status$nix_shell''\n[╰─](red)$status$character ''\n''; + format = ''''\n[╭─\[](red)$username[@](red)$hostname[\]](red)$directory$git_branch$git_status$nix_shell''\n[╰─](red)$status$character ''\n''; - character.format = "[](red)"; + character.format = "[](red)"; - username = { - style_user = "blue"; - style_root = "red bold"; - format = "[$user]($style)"; - show_always = true; - }; + username = { + style_user = "blue"; + style_root = "red bold"; + format = "[$user]($style)"; + show_always = true; + }; - hostname = { - ssh_only = false; - style = "green"; - format = "[$hostname]($style)"; - }; + hostname = { + ssh_only = false; + style = "green"; + format = "[$hostname]($style)"; + }; - directory = { - style = "purple"; - truncate_to_repo = false; - format = mkSegment "$path"; - }; + directory = { + style = "purple"; + truncate_to_repo = false; + format = mkSegment "$path"; + }; - git_branch = { - style = "bold yellow"; - format = ''[┄\[](red)[$symbol$branch(:$remote_branch)]($style)''; - }; + git_branch = { + style = "bold yellow"; + format = ''[┄\[](red)[$symbol$branch(:$remote_branch)]($style)''; + }; - git_status = { - style = "cyan"; - format = ''( [$all_status$ahead_behind]($style))[\]](red)''; - }; + git_status = { + style = "cyan"; + format = ''( [$all_status$ahead_behind]($style))[\]](red)''; + }; - nix_shell = { - format = mkSegment "$symbol $state( \($name\))"; - symbol = ""; - impure_msg = ""; - pure_msg = ""; - }; + nix_shell = { + format = mkSegment "$symbol $state( \($name\))"; + symbol = ""; + impure_msg = ""; + pure_msg = ""; + }; - status = { - disabled = false; - format = "${mkSegment "$symbol $status"}[┄─](red)"; - style = "white"; - }; + status = { + disabled = false; + format = "${mkSegment "$symbol $status"}[┄─](red)"; + style = "white"; }; + }; }; }; } diff --git a/modules/terminal/tmux/default.nix b/modules/terminal/tmux/default.nix index c9ea17b..b122c87 100644 --- a/modules/terminal/tmux/default.nix +++ b/modules/terminal/tmux/default.nix @@ -2,8 +2,12 @@ { config, lib, + pkgs, ... }: +let + cfg = config.terminal.tmux; +in { options.terminal.tmux = { enable = lib.mkEnableOption "Enables tmux."; @@ -15,7 +19,7 @@ }; }; - config = lib.mkIf config.terminal.tmux.enable { + config = lib.mkIf cfg.enable { programs.tmux = { enable = true; }; diff --git a/modules/terminal/zsh/default.nix b/modules/terminal/zsh/default.nix index 8b7897c..4764618 100644 --- a/modules/terminal/zsh/default.nix +++ b/modules/terminal/zsh/default.nix @@ -2,8 +2,14 @@ { config, lib, + pkgs, ... }: +let + cfg = config.terminal.zsh; + + nixCommandWrappers = builtins.readFile ./nix-aliases.sh; +in { options.terminal.zsh = { enable = lib.mkEnableOption "Enables zsh."; @@ -15,21 +21,17 @@ }; }; - config = - let - nixCommandWrappers = builtins.readFile ./nix-aliases.sh; - in - lib.mkIf config.terminal.zsh.enable { - programs.zsh = { - enable = true; - dotDir = "${config.xdg.configHome}/zsh"; - history.path = "${config.xdg.cacheHome}/zsh/history"; - enableCompletion = true; - initContent = builtins.replaceStrings [ "@@NIX_COMMAND_WRAPPERS@@" ] [ nixCommandWrappers ] ( - builtins.readFile ./init.sh - ); - }; - - home.sessionVariables.SHELL = "${lib.getExe config.terminal.zsh.package}"; + config = lib.mkIf cfg.enable { + programs.zsh = { + enable = true; + dotDir = "${config.xdg.configHome}/zsh"; + history.path = "${config.xdg.cacheHome}/zsh/history"; + enableCompletion = true; + initContent = builtins.replaceStrings [ "@@NIX_COMMAND_WRAPPERS@@" ] [ nixCommandWrappers ] ( + builtins.readFile ./init.sh + ); }; + + home.sessionVariables.SHELL = "${lib.getExe cfg.package}"; + }; } |
