/ system / home / default.nix
default.nix
  1  {
  2    config,
  3    lib,
  4    pkgs,
  5    inputs,
  6    ...
  7  }:
  8  let
  9    inherit (builtins) attrNames concatStringsSep map;
 10    inherit (lib) mapAttrsToList mkForce;
 11  
 12    completeAliases = map (alias: "complete -F _complete_alias ${alias}") (
 13      attrNames config.programs.bash.shellAliases
 14    );
 15  in
 16  {
 17    imports = [
 18      inputs.agenix.homeManagerModules.default
 19      inputs.catppuccin.homeModules.catppuccin
 20  
 21      ./git.nix
 22      ./jujutsu.nix
 23      ./zed
 24    ];
 25  
 26    config = {
 27      catppuccin = {
 28        enable = true;
 29        nvim.enable = false;
 30      };
 31  
 32      fonts.fontconfig.enable = true;
 33  
 34      home = {
 35        inherit (config.dusk) username;
 36  
 37        file.".aiderignore".text = ''
 38          *.age
 39          *.lock
 40          /.git
 41          /.github
 42          /.gitignore
 43          LICENSE
 44          LICENSE*
 45        '';
 46  
 47        homeDirectory = mkForce config.dusk.folders.home;
 48  
 49        stateVersion = "25.05";
 50      };
 51  
 52      manual = {
 53        manpages.enable = true;
 54        json.enable = true;
 55        html.enable = true;
 56      };
 57  
 58      news.display = "show";
 59  
 60      programs = {
 61        atuin = {
 62          enable = true;
 63  
 64          flags = [ "--disable-up-arrow" ];
 65  
 66          settings = {
 67            auto_sync = false;
 68            update_check = false;
 69            style = "compact";
 70            show_help = false;
 71  
 72            history_filter = [
 73              "^ls"
 74              "^fg"
 75              "^jobs"
 76              "^kill"
 77              "^pkill"
 78              "^reset"
 79            ] ++ (map (alias: ''"^${alias}"'') (attrNames config.programs.bash.shellAliases));
 80          };
 81        };
 82  
 83        bash = {
 84          enable = true;
 85          enableCompletion = true;
 86  
 87          shellAliases = {
 88            ack = "rg";
 89            bc = "eva";
 90            cat = "bat --decorations=never";
 91            g = "git status --short";
 92            ga = "git add";
 93            gaa = "git add -A";
 94            gaai = "git add --intent-to-add -A";
 95            gai = "git add --intent-to-add";
 96            gc = "git commit";
 97            gca = "git commit -a";
 98            gco = "git checkout";
 99            gcp = "git cherry-pick";
100            gd = "git diff";
101            gf = "git fetch -a --tags";
102            gl = "git log --graph";
103            gp = "git push";
104            gs = "git stash";
105            gsp = "git stash pop";
106            htop = "btop";
107            j = "jj";
108            jc = "jj commit";
109            jd = "jj diff";
110            jl = "jj log --no-pager --ignore-working-copy";
111            ll = mkForce "lsd -l -A";
112            ls = mkForce "lsd -l";
113            vi = "nvim";
114            vim = "nvim";
115          };
116  
117          sessionVariables = {
118            COLORTERM = "truecolor";
119            EDITOR = "${config.programs.neovim.package}/bin/nvim";
120            CDPATH = ".:${config.dusk.folders.code}:${config.dusk.folders.home}";
121            MANPAGER = "${pkgs.less}/bin/less -s -M +Gg";
122            MAN_PAGER = "sh -c 'col -bx | bat -l man -p'";
123          };
124  
125          historySize = 1000000;
126  
127          # Ignore common transaction commands and the aliases we've set.
128          historyIgnore = [
129            "ls"
130            "fg"
131            "jobs"
132            "kill"
133            "killall"
134            "pkill"
135            "reset"
136          ] ++ (mapAttrsToList (key: _: key) config.programs.bash.shellAliases);
137  
138          shellOptions = [
139            # Default options from home-manager
140            "histappend"
141            "checkwinsize"
142            "extglob"
143            "globstar"
144            "checkjobs"
145  
146            # Custom Options
147            "cdspell" # Correct transpositions and other minor details from 'cd DIR' command.
148            "dotglob" # Include hidden files in glob (*).
149            "extglob" # Extra-special pattern matching in the shell.
150            "cmdhist" # Flatten multiple-line commands into the same history entry.
151            "no_empty_cmd_completion" # Don't complete when I haven't typed anything.
152            "shift_verbose" # Let me know if I shift stupidly.
153          ];
154  
155          initExtra = ''
156            . ${pkgs.complete-alias}/bin/complete_alias
157            ${concatStringsSep "\n" completeAliases}
158  
159            if [ "$(uname -s)" == "Darwin" ]; then
160              export PATH="/run/current-system/sw/bin:$PATH:/opt/homebrew/bin"
161  
162              ssh-tmux() {
163                ssh ''${@} -t "tmux -CC attach-session || tmux -CC new-session"
164              }
165            fi
166  
167            # shellcheck disable=SC2086
168            [ -f $HOME/dusk-env.sh ] && . $HOME/dusk-env.sh
169          '';
170        };
171  
172        bat.enable = true;
173  
174        btop = {
175          enable = true;
176  
177          settings = {
178            true_color = true;
179            vim_keys = true;
180          };
181        };
182  
183        direnv = {
184          enable = true;
185  
186          nix-direnv.enable = true;
187  
188          config.global = {
189            load_dotenv = true;
190            hide_env_diff = true;
191            strict_env = true;
192          };
193        };
194  
195        gpg.enable = true;
196        home-manager.enable = true;
197        jq.enable = true;
198        nix-index.enable = true;
199  
200        lsd = {
201          enable = true;
202  
203          settings = {
204            blocks = [
205              "permission"
206              "user"
207              "size"
208              "git"
209              "name"
210            ];
211            icons.theme = "fancy";
212            ignore-globs = [
213              ".direnv"
214              ".git"
215              ".hg"
216              ".jj"
217              "target"
218            ];
219            permission = "rwx";
220          };
221        };
222  
223        neovim = {
224          enable = true;
225          package = pkgs.nightvim;
226        };
227  
228        readline = {
229          enable = true;
230  
231          extraConfig = ''
232            # If there's more than one completion for an input, list all options immediately
233            # instead of waiting for a second input.
234            set show-all-if-ambiguous on
235  
236            # Use arrow keys to search history from cursor position
237            "\e[A":history-search-backward
238            "\e[B":history-search-forward
239  
240            # Do the same for Ctrl-P and Ctrl-N
241            "\C-p":history-search-backward
242            "\C-n":history-search-forward
243          '';
244        };
245  
246        ssh.hashKnownHosts = true;
247        zoxide.enable = true;
248      };
249  
250      xdg = {
251        enable = true;
252  
253        configFile."pgcli/config".text = ''
254          max_field_width = 
255          less_chatty = True
256        '';
257      };
258    };
259  }