From 01aaa7ad39c1fe8af6ffbca31abbab27dbfefc95 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Wed, 15 Jul 2026 20:02:29 +0530 Subject: refactor: organized the modules into better categories Instead of lumping everything in modules/programs we are separating them into separate directories in modules/ --- modules/terminal/bat/base16.mustache.tmTheme | 534 +++++++++++++++++++++++++++ modules/terminal/bat/default.nix | 26 ++ modules/terminal/default.nix | 13 + modules/terminal/fzf/assertions.nix | 13 + modules/terminal/fzf/default.nix | 51 +++ modules/terminal/kitty/default.nix | 55 +++ modules/terminal/less/default.nix | 15 + modules/terminal/starship/default.nix | 63 ++++ modules/terminal/tmux/default.nix | 15 + modules/terminal/zsh/default.nix | 38 ++ modules/terminal/zsh/nix-aliases.sh | 27 ++ 11 files changed, 850 insertions(+) create mode 100644 modules/terminal/bat/base16.mustache.tmTheme create mode 100644 modules/terminal/bat/default.nix create mode 100644 modules/terminal/default.nix create mode 100644 modules/terminal/fzf/assertions.nix create mode 100644 modules/terminal/fzf/default.nix create mode 100644 modules/terminal/kitty/default.nix create mode 100644 modules/terminal/less/default.nix create mode 100644 modules/terminal/starship/default.nix create mode 100644 modules/terminal/tmux/default.nix create mode 100644 modules/terminal/zsh/default.nix create mode 100644 modules/terminal/zsh/nix-aliases.sh (limited to 'modules/terminal') diff --git a/modules/terminal/bat/base16.mustache.tmTheme b/modules/terminal/bat/base16.mustache.tmTheme new file mode 100644 index 0000000..6b2cd5b --- /dev/null +++ b/modules/terminal/bat/base16.mustache.tmTheme @@ -0,0 +1,534 @@ + + + + + name + OneDark Dark + author + olimorris (https://github.com/olimorris) + settings + + + + + settings + + background + #{{base00}} + foreground + #{{base05}} + caret + #{{base05}} + invisibles + #{{base03}} + lineHighlight + #{{base01}} + selection + #{{base02}} + selectionBorder + #{{base03}} + findHighlight + #{{base0A}} + findHighlightForeground + #{{base00}} + activeGuide + #{{base03}} + bracketsForeground + #{{base05}} + bracketsOptions + underline + bracketContentsForeground + #{{base05}} + bracketContentsOptions + underline + tagsOptions + stippled_underline + gutterForeground + #{{base03}} + gutter + #{{base01}} + + + + + + name + Comment + scope + comment, punctuation.definition.comment + settings + + foreground + #{{base03}} + fontStyle + italic + + + + + + name + Variable + scope + variable, variable.other + settings + + foreground + #{{base05}} + + + + + name + Variable - Language + scope + variable.language + settings + + foreground + #{{base0E}} + fontStyle + italic + + + + + + name + Keyword + scope + keyword, keyword.control + settings + + foreground + #{{base0E}} + + + + + name + Keyword - Operator + scope + keyword.operator + settings + + foreground + #{{base0C}} + + + + + + name + Storage + scope + storage, storage.type, storage.modifier + settings + + foreground + #{{base0E}} + + + + + + name + Constant + scope + constant, constant.other + settings + + foreground + #{{base09}} + + + + + name + Constant - Numeric + scope + constant.numeric + settings + + foreground + #{{base09}} + + + + + name + Constant - Language + scope + constant.language + settings + + foreground + #{{base09}} + + + + + name + Constant - Character Escape + scope + constant.character.escape + settings + + foreground + #{{base0C}} + + + + + + name + String + scope + string + settings + + foreground + #{{base0B}} + + + + + name + String - Punctuation + scope + punctuation.definition.string + settings + + foreground + #{{base0B}} + + + + + + name + Support - Function + scope + support.function + settings + + foreground + #{{base0D}} + + + + + name + Support - Class + scope + support.class + settings + + foreground + #{{base0A}} + + + + + name + Support - Type + scope + support.type + settings + + foreground + #{{base0C}} + + + + + name + Support - Constant + scope + support.constant + settings + + foreground + #{{base09}} + + + + + + name + Entity - Name - Function + scope + entity.name.function + settings + + foreground + #{{base0D}} + + + + + name + Entity - Name - Class / Type + scope + entity.name.class, entity.name.type, entity.name.type.class + settings + + foreground + #{{base0A}} + + + + + name + Entity - Name - Tag + scope + entity.name.tag + settings + + foreground + #{{base08}} + + + + + name + Entity - Other - Attribute Name + scope + entity.other.attribute-name + settings + + foreground + #{{base09}} + + + + + name + Entity - Other - Inherited Class + scope + entity.other.inherited-class + settings + + foreground + #{{base0A}} + fontStyle + italic + + + + + + name + Punctuation + scope + punctuation + settings + + foreground + #{{base05}} + + + + + name + Punctuation - Section + scope + punctuation.section, meta.brace + settings + + foreground + #{{base05}} + + + + + + name + Invalid + scope + invalid + settings + + foreground + #{{base07}} + background + #{{base08}} + + + + + name + Invalid - Deprecated + scope + invalid.deprecated + settings + + foreground + #{{base07}} + background + #{{base0F}} + + + + + + name + Diff - Inserted + scope + markup.inserted + settings + + foreground + #{{base0B}} + + + + + name + Diff - Deleted + scope + markup.deleted + settings + + foreground + #{{base08}} + + + + + name + Diff - Changed + scope + markup.changed + settings + + foreground + #{{base0E}} + + + + + + name + Markup - Heading + scope + markup.heading, entity.name.section + settings + + foreground + #{{base0D}} + fontStyle + bold + + + + + name + Markup - Bold + scope + markup.bold + settings + + foreground + #{{base09}} + fontStyle + bold + + + + + name + Markup - Italic + scope + markup.italic + settings + + foreground + #{{base0E}} + fontStyle + italic + + + + + name + Markup - Inline Code + scope + markup.inline.raw, markup.raw.inline + settings + + foreground + #{{base0C}} + + + + + name + Markup - Link + scope + markup.underline.link, string.other.link + settings + + foreground + #{{base0D}} + fontStyle + underline + + + + + name + Markup - Quote + scope + markup.quote + settings + + foreground + #{{base0B}} + fontStyle + italic + + + + + name + Markup - List + scope + markup.list, punctuation.definition.list + settings + + foreground + #{{base08}} + + + + + + name + Meta - Function Call + scope + meta.function-call + settings + + foreground + #{{base0D}} + + + + + name + Meta - Preprocessor + scope + meta.preprocessor + settings + + foreground + #{{base09}} + + + + + uuid + a6f0d8c2-3b1e-4f5a-9c7d-2e8b0f4a6d1c + + diff --git a/modules/terminal/bat/default.nix b/modules/terminal/bat/default.nix new file mode 100644 index 0000000..3c962a3 --- /dev/null +++ b/modules/terminal/bat/default.nix @@ -0,0 +1,26 @@ +{ + config, + lib, + pkgs, + ... +}: + +# bat - a cat clone with wings +{ + config = lib.mkIf config.programs.bat.enable { + programs.bat = { + config = { + theme = "base16"; + }; + themes = { + base16 = { + src = pkgs.runCommand "bat-base16-theme" { } '' + mkdir -p $out + cp ${config.scheme { template = ./base16.mustache.tmTheme; }} $out/base16.tmTheme + ''; + file = "base16.tmTheme"; + }; + }; + }; + }; +} diff --git a/modules/terminal/default.nix b/modules/terminal/default.nix new file mode 100644 index 0000000..7a3ffcc --- /dev/null +++ b/modules/terminal/default.nix @@ -0,0 +1,13 @@ +{ ... }: + +{ + imports = [ + ./bat + ./fzf + ./kitty + ./less + ./starship + ./tmux + ./zsh + ]; +} diff --git a/modules/terminal/fzf/assertions.nix b/modules/terminal/fzf/assertions.nix new file mode 100644 index 0000000..7c2e79c --- /dev/null +++ b/modules/terminal/fzf/assertions.nix @@ -0,0 +1,13 @@ +{ config, ... }: +{ + assertions = [ + { + assertion = + !config.programs.fzf.enable || config.programs.zsh.enable || config.programs.bash.enable; + message = '' + programs.fzf is enabled but neither programs.zsh.enable nor programs.bash.enable is set. + fzf shell integration requires zsh or bash. Please enable at least one. + ''; + } + ]; +} diff --git a/modules/terminal/fzf/default.nix b/modules/terminal/fzf/default.nix new file mode 100644 index 0000000..7671b3c --- /dev/null +++ b/modules/terminal/fzf/default.nix @@ -0,0 +1,51 @@ +{ config, lib, ... }: + +# FZF - Fuzzy finder, CLI fuzzy search tool +{ + imports = [ ./assertions.nix ]; + + config = + let + shellIntegration = '' + ${if config.programs.zsh.enable then "eval \"$(fzf --zsh)\"" else "eval \"$(fzf --bash)\""} + ''; + in + lib.mkIf config.programs.fzf.enable { + programs.fzf = { + defaultOptions = [ + "--height 100%" + "--layout=reverse" + ''--pointer=\" \"'' + ''--header=\" \"'' + ''--prompt=\" \"'' + ''--marker=\"✓ \"'' + "--border=none" + "--cycle" + "--no-info" + "--margin=\"1,2\"" + ]; + + colors = with config.scheme.withHashtag; { + fg = base05; # Foreground + bg = "-1"; # Background (-1 for transparent) + hl = base0D; # Highlight + + "fg+" = base07; # Foreground for selected item + "bg+" = "-1"; # Background for selected item + "hl+" = base0D; # Highlight for selected item + + gutter = "-1"; # Remove the white margin at the left + + info = base0B; # Info text (usually count of items) + border = base03; # Border color + prompt = base0A; # Prompt text color + pointer = base0F; # Pointer color (e.g., > for selected) + marker = base0C; # Marker color (e.g., for multi-select) + spinner = base0C; # Spinner color (during search) + }; + }; + + programs.zsh.initContent = lib.mkIf config.programs.zsh.enable (lib.mkAfter shellIntegration); + programs.bash.initExtra = lib.mkIf config.programs.bash.enable (lib.mkAfter shellIntegration); + }; +} diff --git a/modules/terminal/kitty/default.nix b/modules/terminal/kitty/default.nix new file mode 100644 index 0000000..3701180 --- /dev/null +++ b/modules/terminal/kitty/default.nix @@ -0,0 +1,55 @@ +{ + config, + lib, + ... +}: + +# Kitty - GPU-accelerated terminal emulator +{ + config = lib.mkIf config.programs.kitty.enable { + xdg.mimeApps.defaultApplications = { + "x-scheme-handler/terminal" = "kitty.desktop"; + }; + + programs.kitty = { + settings = with config.scheme.withHashtag; { + window_padding_width = 10; + font_size = config.fonts.size; + font_family = config.fonts.normal; + filter_notification = "all"; + update_check_interval = 0; + scrollback_indicator_opacity = "0.5"; + + dynamic_background_opacity = false; + enable_audio_bell = false; + + background = base00; + foreground = base05; + + color0 = base00; + color1 = base08; + color2 = base0B; + color3 = base0A; + color4 = base0D; + color5 = base0E; + color6 = base0C; + color7 = base05; + color8 = base03; + color9 = base09; + color10 = base0B; + color11 = base0A; + color12 = base0D; + color13 = base0E; + color14 = base0F; + color15 = base07; + + selection_background = base05; + selection_foreground = base00; + + allow_remote_control = "yes"; + listen_on = "unix:/tmp/kitty"; + shell = lib.mkIf config.programs.zsh.enable (lib.getExe config.programs.zsh.package); + }; + }; + }; +} diff --git a/modules/terminal/less/default.nix b/modules/terminal/less/default.nix new file mode 100644 index 0000000..516377d --- /dev/null +++ b/modules/terminal/less/default.nix @@ -0,0 +1,15 @@ +{ config, lib, ... }: + +# less - terminal pager +{ + config = lib.mkIf config.programs.less.enable { + programs.less = { + options = [ + "--RAW-CONTROL-CHARS" + "--quit-if-one-screen" + "--no-init" + "--ignore-case" + ]; + }; + }; +} diff --git a/modules/terminal/starship/default.nix b/modules/terminal/starship/default.nix new file mode 100644 index 0000000..ae5e082 --- /dev/null +++ b/modules/terminal/starship/default.nix @@ -0,0 +1,63 @@ +{ config, lib, ... }: + +# Starship - Minimal, blazing-fast shell prompt +{ + config = lib.mkIf config.programs.starship.enable { + programs.starship = { + enableZshIntegration = config.programs.zsh.enable; + settings = + let + mkSegment = content: ''[┄\[](red)[${content}]($style)[\]](red)''; + in + { + add_newline = true; + + format = ''''\n[╭─\[](red)$username[@](red)$hostname[\]](red)$directory$git_branch$git_status$nix_shell''\n[╰─](red)$status$character ''\n''; + + character.format = "[](red)"; + + username = { + style_user = "blue"; + style_root = "red bold"; + format = "[$user]($style)"; + show_always = true; + }; + + hostname = { + ssh_only = false; + style = "green"; + format = "[$hostname]($style)"; + }; + + directory = { + style = "purple"; + truncate_to_repo = false; + format = mkSegment "$path"; + }; + + git_branch = { + style = "bold yellow"; + format = ''[┄\[](red)[$symbol$branch(:$remote_branch)]($style)''; + }; + + git_status = { + style = "cyan"; + format = ''( [$all_status$ahead_behind]($style))[\]](red)''; + }; + + nix_shell = { + format = mkSegment "$symbol $state( \($name\))"; + symbol = "󱄅"; + impure_msg = "󰻌"; + pure_msg = "󰕥"; + }; + + status = { + disabled = false; + format = "${mkSegment "$symbol $status"}[┄─](red)"; + style = "white"; + }; + }; + }; + }; +} diff --git a/modules/terminal/tmux/default.nix b/modules/terminal/tmux/default.nix new file mode 100644 index 0000000..e2e76c9 --- /dev/null +++ b/modules/terminal/tmux/default.nix @@ -0,0 +1,15 @@ +{ + config, + lib, + pkgs, + ... +}: + +# Tmux - Terminal multiplexer (window/pane management) +{ + config = lib.mkIf config.programs.tmux.enable { + programs.tmux = { + package = pkgs.tmux; + }; + }; +} diff --git a/modules/terminal/zsh/default.nix b/modules/terminal/zsh/default.nix new file mode 100644 index 0000000..f3bdbb1 --- /dev/null +++ b/modules/terminal/zsh/default.nix @@ -0,0 +1,38 @@ +{ + config, + lib, + pkgs, + ... +}: + +# Zsh - Z shell, extended bash with additional features and plugins +{ + config = + let + nixCommandWrappers = builtins.readFile ./nix-aliases.sh; + in + lib.mkIf config.programs.zsh.enable { + programs.zsh = { + package = pkgs.zsh; + dotDir = "${config.xdg.configHome}/zsh"; + history.path = "${config.xdg.cacheHome}/zsh/history"; + enableCompletion = true; + initContent = '' + setopt PROMPT_SUBST + + autoload -U colors && colors + + export GPG_TTY="$(tty)" + gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1 + + bindkey "^[[3~" delete-char + bindkey "^?" backward-delete-char + ${nixCommandWrappers} + ''; + }; + + programs.bash.initExtra = lib.mkIf config.programs.bash.enable (lib.mkAfter nixCommandWrappers); + + home.sessionVariables.SHELL = "${lib.getExe config.programs.zsh.package}"; + }; +} diff --git a/modules/terminal/zsh/nix-aliases.sh b/modules/terminal/zsh/nix-aliases.sh new file mode 100644 index 0000000..0a2f453 --- /dev/null +++ b/modules/terminal/zsh/nix-aliases.sh @@ -0,0 +1,27 @@ +nix-shell() { + for arg in "$@"; do + if [[ "$arg" == "--run" || "$arg" == "--command" ]]; then + command nix-shell "$@" + return + fi + done + + command nix-shell "$@" --run "$SHELL" +} + +nix() { + if [[ "$1" == "develop" ]]; then + local args=("${@:2}") + + for arg in "${args[@]}"; do + if [[ "$arg" == "-c" || "$arg" == "--command" ]]; then + command nix "$@" + return + fi + done + + command nix develop "${args[@]}" -c "$SHELL" + else + command nix "$@" + fi +} -- cgit v1.2.3