Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 1 | { |
| 2 | config, |
| 3 | lib, |
| 4 | pkgs, |
| 5 | ... |
| 6 | }: |
| 7 | { |
| 8 | options.chimera.shell = { |
| 9 | rebuildFlakePath = lib.mkOption { |
| 10 | type = lib.types.nullOr lib.types.str; |
| 11 | description = "Full path to where you store your flake locally"; |
| 12 | default = null; |
| 13 | }; |
| 14 | defaultAliases.enable = lib.mkEnableOption "Use sensible custom aliases"; |
| 15 | usefulPackages.enable = lib.mkEnableOption "Enable useful shell packages (ripgrep, wget, etc)"; |
Skyler Grey | b070038 | 2024-06-30 23:16:17 +0000 | [diff] [blame] | 16 | |
| 17 | tsStatus.enable = lib.mkEnableOption "Enable ts-status alias for better viewing of tailscale status."; |
| 18 | |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 19 | replacements = { |
Samuel Shuert | f51d049 | 2024-02-21 21:52:27 +0000 | [diff] [blame] | 20 | defaultEnable = lib.mkEnableOption "Enable replacing everything by default"; |
| 21 | |
Samuel Shuert | ae46a69 | 2024-03-03 10:47:35 -0500 | [diff] [blame] | 22 | atuin = { |
| 23 | enable = lib.mkOption { |
| 24 | description = "Use atuin instead of bkd-i-search"; |
| 25 | type = lib.types.bool; |
| 26 | default = config.chimera.shell.replacements.defaultEnable; |
| 27 | example = true; |
| 28 | }; |
| 29 | enableUpArrow = lib.mkEnableOption "Pressing up arrow will enter atuin instead of scrolling back through history"; |
| 30 | }; |
| 31 | |
Samuel Shuert | f51d049 | 2024-02-21 21:52:27 +0000 | [diff] [blame] | 32 | eza.enable = lib.mkOption { |
| 33 | description = "Use eza instead of ls"; |
| 34 | type = lib.types.bool; |
| 35 | default = config.chimera.shell.replacements.defaultEnable; |
| 36 | example = true; |
| 37 | }; |
| 38 | bfs.enable = lib.mkOption { |
| 39 | description = "Use bfs instead of find"; |
| 40 | type = lib.types.bool; |
| 41 | default = config.chimera.shell.replacements.defaultEnable; |
| 42 | example = true; |
| 43 | }; |
| 44 | ripgrep.enable = lib.mkOption { |
| 45 | description = "Use ripgrep instead of grep"; |
| 46 | type = lib.types.bool; |
| 47 | default = config.chimera.shell.replacements.defaultEnable; |
| 48 | example = true; |
| 49 | }; |
| 50 | htop.enable = lib.mkOption { |
| 51 | description = "Use htop instead of top"; |
| 52 | type = lib.types.bool; |
| 53 | default = config.chimera.shell.replacements.defaultEnable; |
| 54 | example = true; |
| 55 | }; |
| 56 | erdtree.enable = lib.mkOption { |
| 57 | description = "Use erdtree instead of tree"; |
| 58 | type = lib.types.bool; |
| 59 | default = config.chimera.shell.replacements.defaultEnable; |
| 60 | example = true; |
| 61 | }; |
| 62 | dust.enable = lib.mkOption { |
| 63 | description = "Use dust instead of du"; |
| 64 | type = lib.types.bool; |
| 65 | default = config.chimera.shell.replacements.defaultEnable; |
| 66 | example = true; |
| 67 | }; |
| 68 | bat.enable = lib.mkOption { |
| 69 | description = "Use bat instead of cat"; |
| 70 | type = lib.types.bool; |
| 71 | default = config.chimera.shell.replacements.defaultEnable; |
| 72 | example = true; |
| 73 | }; |
| 74 | zoxide.enable = lib.mkOption { |
| 75 | description = "Use zoxide instead of cd"; |
| 76 | type = lib.types.bool; |
| 77 | default = config.chimera.shell.replacements.defaultEnable; |
| 78 | example = true; |
| 79 | }; |
Samuel Shuert | b652b36 | 2024-06-20 21:37:38 -0400 | [diff] [blame] | 80 | glow.enable = lib.mkOption { |
| 81 | description = "Use glow for cat-ing .md files"; |
| 82 | type = lib.types.bool; |
| 83 | default = config.chimera.shell.replacements.defaultEnable; |
| 84 | example = true; |
| 85 | }; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 86 | }; |
| 87 | }; |
| 88 | |
| 89 | config = { |
Samuel Shuert | b652b36 | 2024-06-20 21:37:38 -0400 | [diff] [blame] | 90 | home.shellAliases = lib.mkIf config.chimera.shell.defaultAliases.enable ( |
| 91 | let |
| 92 | any_cat_replacement = config.chimera.shell.replacements.glow.enable || config.chimera.shell.replacements.bat.enable; |
| 93 | cat_or_bat = if config.chimera.shell.replacements.bat.enable then "${pkgs.bat}/bin/bat" else "${pkgs.coreutils}/bin/cat"; |
| 94 | glow_or_cat_or_bat = if config.chimera.shell.replacements.glow.enable |
| 95 | then builtins.toString (pkgs.writeScript "glow_or_cat_or_bat" '' |
| 96 | if [[ "$1" == *.md ]]; then |
| 97 | ${pkgs.glow}/bin/glow "$@" |
| 98 | else |
| 99 | ${cat_or_bat} "$@" |
| 100 | fi |
| 101 | '') |
| 102 | else cat_or_bat; |
| 103 | in { |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 104 | rebuild = |
| 105 | lib.mkIf (config.chimera.shell.rebuildFlakePath != null) |
| 106 | "sudo nixos-rebuild switch --flake ${config.chimera.shell.rebuildFlakePath}"; |
| 107 | clr = "clear"; |
Skyler Grey | 1dea6b6 | 2024-03-12 11:41:15 +0000 | [diff] [blame] | 108 | edit = builtins.toString config.home.sessionVariables.EDITOR; |
Skyler Grey | e3f77dc | 2024-02-25 13:17:34 +0000 | [diff] [blame] | 109 | find = lib.mkIf config.chimera.shell.replacements.bfs.enable "${pkgs.bfs}/bin/bfs"; |
Skyler Grey | 1ab2c1a | 2024-05-24 23:29:22 +0000 | [diff] [blame] | 110 | grep = lib.mkIf config.chimera.shell.replacements.ripgrep.enable "${config.programs.ripgrep.package}/bin/rg --include-zero"; |
Skyler Grey | e3f77dc | 2024-02-25 13:17:34 +0000 | [diff] [blame] | 111 | top = lib.mkIf config.chimera.shell.replacements.htop.enable "${config.programs.htop.package}/bin/htop"; |
| 112 | tree = lib.mkIf config.chimera.shell.replacements.erdtree.enable "${pkgs.erdtree}/bin/erdtree"; |
| 113 | du = lib.mkIf config.chimera.shell.replacements.dust.enable "${pkgs.dust}/bin/dust"; |
Samuel Shuert | b652b36 | 2024-06-20 21:37:38 -0400 | [diff] [blame] | 114 | cat = lib.mkIf any_cat_replacement glow_or_cat_or_bat; |
Skyler Grey | 55d3edc | 2024-05-25 12:22:30 +0000 | [diff] [blame] | 115 | lix = "${config.nix.package}/bin/nix"; # Lix, like nix |
Skyler Grey | b070038 | 2024-06-30 23:16:17 +0000 | [diff] [blame] | 116 | |
| 117 | ts-status = lib.mkIf config.chimera.shell.tsStatus.enable ''${pkgs.tailscale}/bin/tailscale status | column -t -N "ADDRESS,DOMAIN,USER,OS,STATUS,CONNECTION" -l 6 -o " | "''; |
Samuel Shuert | b652b36 | 2024-06-20 21:37:38 -0400 | [diff] [blame] | 118 | }); |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 119 | |
Skyler Grey | b9fc2cd | 2024-04-05 09:10:39 +0000 | [diff] [blame] | 120 | home.sessionVariables = lib.mkIf (config.chimera.shell.usefulPackages.enable && config.chimera.theme.style == "Light") { |
| 121 | BAT_THEME = "OneHalfLight"; |
| 122 | }; |
| 123 | |
Samuel Shuert | ae46a69 | 2024-03-03 10:47:35 -0500 | [diff] [blame] | 124 | programs.atuin = lib.mkIf config.chimera.shell.replacements.atuin.enable { |
| 125 | enable = true; |
| 126 | enableZshIntegration = config.chimera.shell.zsh.enable; |
| 127 | enableBashIntegration = config.chimera.shell.bash.enable; |
| 128 | flags = lib.mkIf (!config.chimera.shell.replacements.atuin.enableUpArrow) [ "--disable-up-arrow" ]; |
| 129 | }; |
| 130 | |
Samuel Shuert | f51d049 | 2024-02-21 21:52:27 +0000 | [diff] [blame] | 131 | programs.eza = lib.mkIf config.chimera.shell.replacements.eza.enable { |
| 132 | enable = true; |
Skyler Grey | 6b8b30c | 2024-04-20 22:20:37 +0000 | [diff] [blame] | 133 | enableZshIntegration = config.chimera.shell.zsh.enable; |
| 134 | enableBashIntegration = config.chimera.shell.bash.enable; |
Samuel Shuert | f51d049 | 2024-02-21 21:52:27 +0000 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | programs.ripgrep = lib.mkIf config.chimera.shell.replacements.ripgrep.enable { |
| 138 | enable = true; |
| 139 | arguments = [ "--smart-case" ]; |
| 140 | }; |
| 141 | |
Samuel Shuert | 659b564 | 2024-02-23 20:47:43 +0000 | [diff] [blame] | 142 | programs.htop = lib.mkIf config.chimera.shell.replacements.htop.enable { enable = true; }; |
Samuel Shuert | f51d049 | 2024-02-21 21:52:27 +0000 | [diff] [blame] | 143 | |
| 144 | programs.zoxide = lib.mkIf config.chimera.shell.replacements.zoxide.enable { |
| 145 | enable = true; |
| 146 | enableZshIntegration = config.chimera.shell.zsh.enable; |
| 147 | enableBashIntegration = config.chimera.shell.bash.enable; |
| 148 | options = [ "--cmd cd" ]; |
| 149 | }; |
| 150 | |
| 151 | programs.tealdeer = lib.mkIf config.chimera.shell.usefulPackages.enable { |
Samuel Shuert | f51d049 | 2024-02-21 21:52:27 +0000 | [diff] [blame] | 152 | enable = true; |
Samuel Shuert | 3288787 | 2024-03-02 12:18:33 -0500 | [diff] [blame] | 153 | settings.updates = { |
| 154 | auto_update = true; |
| 155 | auto_update_interval_hours = 72; |
| 156 | }; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 157 | }; |
Samuel Shuert | 659b564 | 2024-02-23 20:47:43 +0000 | [diff] [blame] | 158 | programs.jq = lib.mkIf config.chimera.shell.usefulPackages.enable { enable = true; }; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 159 | |
| 160 | home.packages = |
| 161 | ( |
| 162 | if config.chimera.shell.usefulPackages.enable then |
| 163 | [ |
| 164 | pkgs.wget |
Skyler Grey | b9fc2cd | 2024-04-05 09:10:39 +0000 | [diff] [blame] | 165 | pkgs.bat |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 166 | pkgs.curl |
| 167 | pkgs.curlie |
| 168 | pkgs.pv |
| 169 | pkgs.sd |
| 170 | pkgs.tokei |
| 171 | pkgs.hyperfine |
Samuel Shuert | f51d049 | 2024-02-21 21:52:27 +0000 | [diff] [blame] | 172 | pkgs.tmux |
Samuel Shuert | b652b36 | 2024-06-20 21:37:38 -0400 | [diff] [blame] | 173 | pkgs.glow |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 174 | ] |
| 175 | else |
| 176 | [ ] |
| 177 | ) |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 178 | ++ (if config.chimera.shell.replacements.bfs.enable then [ pkgs.bfs ] else [ ]) |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 179 | ++ (if config.chimera.shell.replacements.htop.enable then [ pkgs.htop ] else [ ]) |
| 180 | ++ (if config.chimera.shell.replacements.erdtree.enable then [ pkgs.erdtree ] else [ ]) |
Skyler Grey | b9fc2cd | 2024-04-05 09:10:39 +0000 | [diff] [blame] | 181 | ++ (if config.chimera.shell.replacements.dust.enable then [ pkgs.dust ] else [ ]); |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 182 | }; |
| 183 | } |