about summary refs log tree commit diff
path: root/configs/.config/nixpkgs/home.nix
blob: 2011381ab479b34f0ce6e37f96b9c022a0d26df8 (plain) (blame)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
{ config, pkgs, ... }:

let
  briefcase = import <briefcase> {};
in {
  home = {
    packages = with pkgs; [
      bat
      exa
      ripgrep
      fd
      pass
      tokei
      nmap
      tldr
      diskus
      jq
      pup
    ];
    keyboard = {
      options = [
        # Swap Caps-Lock and Escape
        "remove Lock = Caps_Lock"
        "keysym Caps_Lock = Escape"
      ];
    };
    sessionVariables = {
      BROWSER = "google-chrome";
      EDITOR = "emacsclient";
      ALTERNATE_EDITOR = "vim";
    };
    stateVersion = "19.09";
  };

  ##############################################################################
  # Programs
  ##############################################################################

  programs.home-manager = {
    enable = true;
    path = builtins.toPath ~/home-manager;
  };

  programs.git = {
    enable = true;
    package = briefcase.utils.wrapNonNixProgram {
      path = "/usr/bin/git";
      as = "git";
    };
    userName = "William Carroll";
    userEmail = "wpcarro@gmail.com";
    aliases = {
      today = "! git log --date=relative --since=00:00:00 --all --no-merges --oneline --author=\"$(git config --get user.email)\"";
      yday = "! git log --since=yesterday.midnight --until=today.midnight --oneline --author=\"$(git config --get user.email)\"";
      changed-files = "! git --no-pager diff --name-only $(current_branch) $(git merge-base $(current_branch) master)";
      conflicts = "! git --no-pager diff --name-only --diff-filter=U";
      unstage = "reset HEAD --";
    };
    extraConfig = {
      push.default = "current";
      rebase = {
        autosquash = true;
        autostash = true;
      };
      rerere.enabled = true;
    };
  };

  programs.gpg = {
    enable = true;
    settings = {
      keyserver = "hkp://pgp.mit.edu";
    };
  };

  programs.ssh = {
    enable = true;
    matchBlocks = {
      desktop = {
        user = "wpcarro";
        hostname = "zeno.lon.corp.google.com";
      };
      socrates = {
        user = "wpcarro";
        hostname = "84.92.33.141";
      };
    };
  };

  programs.fish = {
    enable = true;
    shellAliases = {
      c = "xclip -selection clipboard -i";
      p = "xclip -selection clipboard -o";
      cat = "bat --theme='Monokai Extended Light'";
      rgh = "rg --hidden";
      fdh = "fd --hidden";
      tpr = "tput reset";
      ls = "exa --sort=type";
      ll = "exa --long --sort=type";
      la = "exa --long --all --sort=type";
      gst = "git status";
      gsh = "git show HEAD";
      gpf = "git push --force-with-lease";
      gd = "git diff";
    };
    shellAbbrs = {
      sys = "systemctl";
      sysst = "systemctl status";
      sysu = "systemctl --user";
      sysust = "systemctl --user status";
    };
    promptInit = builtins.readFile ../fish/prompt.fish;
    functions = {
      ptree = {
        body = ''
          for pid in (pgrep $argv[1])
            pstree -s -p $pid
          end
        '';
      };
    };
  };

  programs.fzf = rec {
    enable = true;
    defaultCommand = "fd --hidden --follow --exclude '.git'";
    fileWidgetCommand = defaultCommand;
    enableFishIntegration = true;
  };

  programs.direnv = {
    enable = true;
    enableFishIntegration = true;
  };

  programs.autorandr = {
    enable = true;
    profiles = let
      # To get these values, I ran `xrandr --props` and searched for
      # 'EDID:'. While these are long and a bit unsightly, I cannot think of a
      # desirable workaround, so I'm going to leave them for now.
      laptop = "00ffffffffffff000daed71400000000151b0104a51f117802ee95a3544c99260f505400000001010101010101010101010101010101363680a0703820402e1e240035ad10000018000000fe004e3134304843452d474e320a20000000fe00434d4e0a202020202020202020000000fe004e3134304843452d474e320a2000e2";
      hdmi4k = "00ffffffffffff001e6d085b6d4a0400061c0103803c2278ea3035a7554ea3260f50542108007140818081c0a9c0d1c081000101010108e80030f2705a80b0588a0058542100001e04740030f2705a80b0588a0058542100001a000000fd00383d1e873c000a202020202020000000fc004c4720556c7472612048440a200150020330714d902220050403020161605d5e5f230907076d030c001000b83c20006001020367d85dc401788003e30f0003023a801871382d40582c450058542100001a565e00a0a0a029503020350058542100001a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000ad";
    in {
      mobile = {
        fingerprint = {
          eDP1 = laptop;
          HDMI1 = hdmi4k;
        };
        config = {
          eDP1 = {
            enable = true;
            primary = true;
            mode = "1920x1080";
            rate = "59.93";
          };
          HDMI1 = {
            enable = false;
          };
        };
      };
      docked = {
        fingerprint = {
          eDP1 = laptop;
          HDMI1 = hdmi4k;
        };
        config = {
          eDP1 = {
            enable = false;
          };
          HDMI1 = {
            enable = true;
            primary = true;
            mode = "3840x2160";
            rate = "30.00";
          };
        };
      };
    };
  };

  ##############################################################################
  # Services
  ##############################################################################

  xsession = {
    enable = true;
    windowManager.command = "dbus-launch --exit-with-session wpcarros-emacs";
  };

  # Filter blue light from screen after sunset.
  services.redshift = {
    enable = true;
    latitude = "51.49";
    longitude = "-0.18";
    package = briefcase.utils.wrapNonNixProgram {
      path = "/usr/bin/redshift";
      as = "redshift";
    };
    # Disable the fading animation.
    extraOptions = [ "-r" ];
  };

  # Hide the cursor during X sessions after 1 second.
  services.unclutter.enable = true;

  # Support mouseless workflows.
  services.keynav.enable = true;

  services.lorri.enable = true;

  services.gpg-agent = {
    enable = true;
    defaultCacheTtl = 8 * 60 * 60; # 8 hours
    maxCacheTtl = 8 * 60 * 60;
  };
}