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