blob: 4b3dff7aa88117074a684ede15c4f62e2e9e35da [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
19 eza.enable = lib.mkOption {
20 description = "Use eza instead of ls";
21 type = lib.types.bool;
22 default = config.chimera.shell.replacements.defaultEnable;
23 example = true;
24 };
25 bfs.enable = lib.mkOption {
26 description = "Use bfs instead of find";
27 type = lib.types.bool;
28 default = config.chimera.shell.replacements.defaultEnable;
29 example = true;
30 };
31 ripgrep.enable = lib.mkOption {
32 description = "Use ripgrep instead of grep";
33 type = lib.types.bool;
34 default = config.chimera.shell.replacements.defaultEnable;
35 example = true;
36 };
37 htop.enable = lib.mkOption {
38 description = "Use htop instead of top";
39 type = lib.types.bool;
40 default = config.chimera.shell.replacements.defaultEnable;
41 example = true;
42 };
43 erdtree.enable = lib.mkOption {
44 description = "Use erdtree instead of tree";
45 type = lib.types.bool;
46 default = config.chimera.shell.replacements.defaultEnable;
47 example = true;
48 };
49 dust.enable = lib.mkOption {
50 description = "Use dust instead of du";
51 type = lib.types.bool;
52 default = config.chimera.shell.replacements.defaultEnable;
53 example = true;
54 };
55 bat.enable = lib.mkOption {
56 description = "Use bat instead of cat";
57 type = lib.types.bool;
58 default = config.chimera.shell.replacements.defaultEnable;
59 example = true;
60 };
61 zoxide.enable = lib.mkOption {
62 description = "Use zoxide instead of cd";
63 type = lib.types.bool;
64 default = config.chimera.shell.replacements.defaultEnable;
65 example = true;
66 };
Samuel Shuert02ffd1e2024-02-13 21:37:15 -050067 };
68 };
69
70 config = {
71 home.shellAliases = lib.mkIf config.chimera.shell.defaultAliases.enable {
72 rebuild =
73 lib.mkIf (config.chimera.shell.rebuildFlakePath != null)
74 "sudo nixos-rebuild switch --flake ${config.chimera.shell.rebuildFlakePath}";
75 clr = "clear";
76 edit = config.home.sessionVariables.EDITOR;
Skyler Greye3f77dc2024-02-25 13:17:34 +000077 find = lib.mkIf config.chimera.shell.replacements.bfs.enable "${pkgs.bfs}/bin/bfs";
78 grep = lib.mkIf config.chimera.shell.replacements.ripgrep.enable "${config.programs.ripgrep.package}/bin/rg";
79 top = lib.mkIf config.chimera.shell.replacements.htop.enable "${config.programs.htop.package}/bin/htop";
80 tree = lib.mkIf config.chimera.shell.replacements.erdtree.enable "${pkgs.erdtree}/bin/erdtree";
81 du = lib.mkIf config.chimera.shell.replacements.dust.enable "${pkgs.dust}/bin/dust";
Samuel Shuertf51d0492024-02-21 21:52:27 +000082 cat = lib.mkIf config.chimera.shell.replacements.bat.enable "${pkgs.bat}/bin/bat";
Samuel Shuert02ffd1e2024-02-13 21:37:15 -050083 };
84
Samuel Shuertf51d0492024-02-21 21:52:27 +000085 programs.eza = lib.mkIf config.chimera.shell.replacements.eza.enable {
86 enable = true;
87 enableAliases = true;
88 };
89
90 programs.ripgrep = lib.mkIf config.chimera.shell.replacements.ripgrep.enable {
91 enable = true;
92 arguments = [ "--smart-case" ];
93 };
94
Samuel Shuert659b5642024-02-23 20:47:43 +000095 programs.htop = lib.mkIf config.chimera.shell.replacements.htop.enable { enable = true; };
Samuel Shuertf51d0492024-02-21 21:52:27 +000096
97 programs.zoxide = lib.mkIf config.chimera.shell.replacements.zoxide.enable {
98 enable = true;
99 enableZshIntegration = config.chimera.shell.zsh.enable;
100 enableBashIntegration = config.chimera.shell.bash.enable;
101 options = [ "--cmd cd" ];
102 };
103
104 programs.tealdeer = lib.mkIf config.chimera.shell.usefulPackages.enable {
Samuel Shuertf51d0492024-02-21 21:52:27 +0000105 enable = true;
Samuel Shuert659b5642024-02-23 20:47:43 +0000106 settings.updates.autoupdate = true;
Samuel Shuert02ffd1e2024-02-13 21:37:15 -0500107 };
Samuel Shuert659b5642024-02-23 20:47:43 +0000108 programs.jq = lib.mkIf config.chimera.shell.usefulPackages.enable { enable = true; };
Samuel Shuert02ffd1e2024-02-13 21:37:15 -0500109
110 home.packages =
111 (
112 if config.chimera.shell.usefulPackages.enable then
113 [
114 pkgs.wget
115 pkgs.curl
116 pkgs.curlie
117 pkgs.pv
118 pkgs.sd
119 pkgs.tokei
120 pkgs.hyperfine
Samuel Shuertf51d0492024-02-21 21:52:27 +0000121 pkgs.tmux
Samuel Shuert02ffd1e2024-02-13 21:37:15 -0500122 ]
123 else
124 [ ]
125 )
Samuel Shuert02ffd1e2024-02-13 21:37:15 -0500126 ++ (if config.chimera.shell.replacements.bfs.enable then [ pkgs.bfs ] else [ ])
Samuel Shuert02ffd1e2024-02-13 21:37:15 -0500127 ++ (if config.chimera.shell.replacements.htop.enable then [ pkgs.htop ] else [ ])
128 ++ (if config.chimera.shell.replacements.erdtree.enable then [ pkgs.erdtree ] else [ ])
129 ++ (if config.chimera.shell.replacements.dust.enable then [ pkgs.dust ] else [ ])
130 ++ (if config.chimera.shell.replacements.bat.enable then [ pkgs.bat ] else [ ]);
131 };
132}