blob: 2924d6d2256425f0536c2ca8b2ce485176c7fc46 [file] [log] [blame]
Samuel Shuert02ffd1e2024-02-13 21:37:15 -05001{
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 Shuertf51d0492024-02-21 21:52:27 +000017 defaultEnable = lib.mkEnableOption "Enable replacing everything by default";
18
Samuel Shuertae46a692024-03-03 10:47:35 -050019 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 Shuertf51d0492024-02-21 21:52:27 +000029 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 Shuert02ffd1e2024-02-13 21:37:15 -050077 };
78 };
79
80 config = {
81 home.shellAliases = lib.mkIf config.chimera.shell.defaultAliases.enable {
82 rebuild =
83 lib.mkIf (config.chimera.shell.rebuildFlakePath != null)
84 "sudo nixos-rebuild switch --flake ${config.chimera.shell.rebuildFlakePath}";
85 clr = "clear";
Skyler Grey1dea6b62024-03-12 11:41:15 +000086 edit = builtins.toString config.home.sessionVariables.EDITOR;
Skyler Greye3f77dc2024-02-25 13:17:34 +000087 find = lib.mkIf config.chimera.shell.replacements.bfs.enable "${pkgs.bfs}/bin/bfs";
88 grep = lib.mkIf config.chimera.shell.replacements.ripgrep.enable "${config.programs.ripgrep.package}/bin/rg";
89 top = lib.mkIf config.chimera.shell.replacements.htop.enable "${config.programs.htop.package}/bin/htop";
90 tree = lib.mkIf config.chimera.shell.replacements.erdtree.enable "${pkgs.erdtree}/bin/erdtree";
91 du = lib.mkIf config.chimera.shell.replacements.dust.enable "${pkgs.dust}/bin/dust";
Samuel Shuertf51d0492024-02-21 21:52:27 +000092 cat = lib.mkIf config.chimera.shell.replacements.bat.enable "${pkgs.bat}/bin/bat";
Samuel Shuert02ffd1e2024-02-13 21:37:15 -050093 };
94
Samuel Shuertae46a692024-03-03 10:47:35 -050095 programs.atuin = lib.mkIf config.chimera.shell.replacements.atuin.enable {
96 enable = true;
97 enableZshIntegration = config.chimera.shell.zsh.enable;
98 enableBashIntegration = config.chimera.shell.bash.enable;
99 flags = lib.mkIf (!config.chimera.shell.replacements.atuin.enableUpArrow) [ "--disable-up-arrow" ];
100 };
101
Samuel Shuertf51d0492024-02-21 21:52:27 +0000102 programs.eza = lib.mkIf config.chimera.shell.replacements.eza.enable {
103 enable = true;
104 enableAliases = true;
105 };
106
107 programs.ripgrep = lib.mkIf config.chimera.shell.replacements.ripgrep.enable {
108 enable = true;
109 arguments = [ "--smart-case" ];
110 };
111
Samuel Shuert659b5642024-02-23 20:47:43 +0000112 programs.htop = lib.mkIf config.chimera.shell.replacements.htop.enable { enable = true; };
Samuel Shuertf51d0492024-02-21 21:52:27 +0000113
114 programs.zoxide = lib.mkIf config.chimera.shell.replacements.zoxide.enable {
115 enable = true;
116 enableZshIntegration = config.chimera.shell.zsh.enable;
117 enableBashIntegration = config.chimera.shell.bash.enable;
118 options = [ "--cmd cd" ];
119 };
120
121 programs.tealdeer = lib.mkIf config.chimera.shell.usefulPackages.enable {
Samuel Shuertf51d0492024-02-21 21:52:27 +0000122 enable = true;
Samuel Shuert32887872024-03-02 12:18:33 -0500123 settings.updates = {
124 auto_update = true;
125 auto_update_interval_hours = 72;
126 };
Samuel Shuert02ffd1e2024-02-13 21:37:15 -0500127 };
Samuel Shuert659b5642024-02-23 20:47:43 +0000128 programs.jq = lib.mkIf config.chimera.shell.usefulPackages.enable { enable = true; };
Samuel Shuert02ffd1e2024-02-13 21:37:15 -0500129
130 home.packages =
131 (
132 if config.chimera.shell.usefulPackages.enable then
133 [
134 pkgs.wget
135 pkgs.curl
136 pkgs.curlie
137 pkgs.pv
138 pkgs.sd
139 pkgs.tokei
140 pkgs.hyperfine
Samuel Shuertf51d0492024-02-21 21:52:27 +0000141 pkgs.tmux
Samuel Shuert02ffd1e2024-02-13 21:37:15 -0500142 ]
143 else
144 [ ]
145 )
Samuel Shuert02ffd1e2024-02-13 21:37:15 -0500146 ++ (if config.chimera.shell.replacements.bfs.enable then [ pkgs.bfs ] else [ ])
Samuel Shuert02ffd1e2024-02-13 21:37:15 -0500147 ++ (if config.chimera.shell.replacements.htop.enable then [ pkgs.htop ] else [ ])
148 ++ (if config.chimera.shell.replacements.erdtree.enable then [ pkgs.erdtree ] else [ ])
149 ++ (if config.chimera.shell.replacements.dust.enable then [ pkgs.dust ] else [ ])
150 ++ (if config.chimera.shell.replacements.bat.enable then [ pkgs.bat ] else [ ]);
151 };
152}