blob: d7c65a506a3c9ec74dd38af7851a170e9a8bd142 [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;
Samuel Shuertf51d0492024-02-21 21:52:27 +000077 find = lib.mkIf config.chimera.shell.replacements.bat.enable "${pkgs.bfs}/bin/bfs";
78 grep = lib.mkIf config.chimera.shell.replacements.bat.enable "${config.programs.ripgrep.package}/bin/rg";
79 top = lib.mkIf config.chimera.shell.replacements.bat.enable "${config.programs.htop.package}/bin/htop";
80 tree = lib.mkIf config.chimera.shell.replacements.bat.enable "${pkgs.erdtree}/bin/erdtree";
81 du = lib.mkIf config.chimera.shell.replacements.bat.enable "${pkgs.dust}/bin/dust";
82 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
95 programs.htop = lib.mkIf config.chimera.shell.replacements.htop.enable {
96 enable = true;
97 };
98
99 programs.zoxide = lib.mkIf config.chimera.shell.replacements.zoxide.enable {
100 enable = true;
101 enableZshIntegration = config.chimera.shell.zsh.enable;
102 enableBashIntegration = config.chimera.shell.bash.enable;
103 options = [ "--cmd cd" ];
104 };
105
106 programs.tealdeer = lib.mkIf config.chimera.shell.usefulPackages.enable {
Samuel Shuert02ffd1e2024-02-13 21:37:15 -0500107 enable = true;
108 settings.updates.autoupdate = true;
Samuel Shuertf51d0492024-02-21 21:52:27 +0000109 };
110 programs.jq = lib.mkIf config.chimera.shell.usefulPackages.enable {
111 enable = true;
Samuel Shuert02ffd1e2024-02-13 21:37:15 -0500112 };
113
114 home.packages =
115 (
116 if config.chimera.shell.usefulPackages.enable then
117 [
118 pkgs.wget
119 pkgs.curl
120 pkgs.curlie
121 pkgs.pv
122 pkgs.sd
123 pkgs.tokei
124 pkgs.hyperfine
Samuel Shuertf51d0492024-02-21 21:52:27 +0000125 pkgs.tmux
Samuel Shuert02ffd1e2024-02-13 21:37:15 -0500126 ]
127 else
128 [ ]
129 )
Samuel Shuert02ffd1e2024-02-13 21:37:15 -0500130 ++ (if config.chimera.shell.replacements.bfs.enable then [ pkgs.bfs ] else [ ])
Samuel Shuert02ffd1e2024-02-13 21:37:15 -0500131 ++ (if config.chimera.shell.replacements.htop.enable then [ pkgs.htop ] else [ ])
132 ++ (if config.chimera.shell.replacements.erdtree.enable then [ pkgs.erdtree ] else [ ])
133 ++ (if config.chimera.shell.replacements.dust.enable then [ pkgs.dust ] else [ ])
134 ++ (if config.chimera.shell.replacements.bat.enable then [ pkgs.bat ] else [ ]);
135 };
136}