ctucx.git: nixfiles

ctucx' nixfiles

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
95 
{ config, pkgs, lib, ... }:

let
  cfg = config.ctucxConfig.programs.bash;

in {

  options = {
    ctucxConfig.programs.bash = {
      enable = lib.mkEnableOption "bash";
    };
  };

  config = lib.mkIf cfg.enable {
    ctucxConfig.programs = {
      starship.enable = true;
      mcfly.enable    = true;
      eza.enable      = true;
    };

    home-manager.users.katja = {
      programs = {
        bash = {
          enable               = true;
          enableVteIntegration = lib.mkIf pkgs.stdenv.isLinux true;

          historyFileSize = 999999;
          historyControl  = [ "ignoredups" "ignorespace" ];
          historyIgnore   = [ "ls" "clear" "exit" ];

          shellAliases    = {
            ".."         = "cd ..";
            "..."        = "cd ../..";

            rm           = "rm -i";

            cat          = lib.mkIf (builtins.elem "bat" config.home-manager.users.katja.home.packages) "bat -p";
            grep         = lib.mkIf (builtins.elem "rg" config.home-manager.users.katja.home.packages)  "rg";
            find         = lib.mkIf (builtins.elem "rd" config.home-manager.users.katja.home.packages)  "fd";

            diff         = "diff --color";

            killall      = "pkill";

            reinitgit    = "rm -rf .git && git init && git add -A && git commit -m 'init'";

            zzz          = (
              if pkgs.stdenv.isLinux then
                "sleep 1 && systemctl suspend"
              else
                "pmset sleepnow"
            );

            backgrounditems     = "bgiparser -f  \"\$HOME/Library/Application Support/com.apple.backgroundtaskmanagementagent/backgrounditems.btm\" -c";

          };

          bashrcExtra = ''
            use() {
              declare -a all
              for p in "$@"; do
                all+=("''${NIXPKGS_PATH}#$p")
              done
              eval nix shell ''${all[@]}
            }
          '' + lib.optionalString pkgs.stdenv.isDarwin ''
            if [ "$TERM" != "dumb" ]; then
              source "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh"
              nullglobStatus=$(shopt -p nullglob)
              shopt -s nullglob
              for p in $NIX_PROFILES; do
                for m in "$p/etc/bash_completion.d/"*; do
                  source $m
                done
              done
              eval "$nullglobStatus"
              unset nullglobStatus p m
            fi

            # Make bash check its window size after a process completes
            shopt -s checkwinsize

            ${if pkgs.system == "aarch64-darwin" then ''
            eval "$(/opt/homebrew/bin/brew shellenv)"
            '' else ''
            eval "$(/usr/local/bin/brew shellenv)"
            ''}
          '';

        };
      };
    };
  };

}