btw i use nix
1{
2 pkgs,
3 config,
4 lib,
5 ...
6}:
7
8let
9 cfg = config.custom;
10in
11{
12 imports = [
13 ./mail.nix
14 ./calendar.nix
15 ./gui/default.nix
16 ./nvim/default.nix
17 ./emacs/default.nix
18 ./battery.nix
19 ];
20
21 options.custom.machineColour = lib.mkOption {
22 type = lib.types.str;
23 default = "cyan";
24 };
25
26 config = {
27 home.sessionVariables = {
28 EDITOR = "nvim";
29 NIX_AUTO_RUN = "y";
30 NIX_AUTO_RUN_INTERACTIVE = "y";
31 GOPATH = "$HOME/.go";
32 };
33 home.packages = with pkgs; [
34 htop
35 gnumake
36 inetutils
37 dig
38 fzf
39 jq
40 bc
41 openssh
42 # multicore rust command line utils
43 dua
44 fd
45 ripgrep
46 ];
47
48 home.shellAliases = {
49 ls = "ls -p --color=auto";
50 pls = "sudo $(fc -ln -1)";
51 o = "xdg-open";
52 se = "sudoedit";
53 su = "su -p";
54 ssh = "TERM=xterm ssh";
55 nix-shell = "nix-shell --command zsh";
56 inhibit-lid = "systemd-inhibit --what=handle-lid-switch sleep 1d";
57 tmux = "tmux -2";
58 feh = "feh --scale-down --auto-zoom";
59 nix-stray-roots = "nix-store --gc --print-roots | egrep -v '^(/nix/var|/run|/proc|{censored})'";
60 };
61
62 # https://github.com/nix-community/home-manager/issues/1439#issuecomment-1106208294
63 home.activation = {
64 linkDesktopApplications = {
65 after = [
66 "writeBoundary"
67 "createXdgUserDirectories"
68 ];
69 before = [ ];
70 data = ''
71 rm -rf ${config.xdg.dataHome}/"applications/home-manager"
72 mkdir -p ${config.xdg.dataHome}/"applications/home-manager"
73 cp -Lr ${config.home.homeDirectory}/.nix-profile/share/applications/* ${config.xdg.dataHome}/"applications/home-manager/"
74 '';
75 };
76 };
77
78 programs.zsh = {
79 enable = true;
80 history = {
81 size = 1000000;
82 path = "$HOME/.histfile";
83 share = false;
84 };
85 autosuggestion.enable = true;
86 syntaxHighlighting.enable = true;
87 enableCompletion = true;
88 initExtraFirst = ''
89 export ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd completion history)
90 export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=5"
91 PROMPT='%(?..%F{red}%3?%f )%F{${config.custom.machineColour}}%n@%m%f:%~ %#'$'\n'
92 '';
93 initExtra = builtins.readFile ./zsh.cfg;
94 };
95
96 programs.bash.initExtra = ''
97 PS1='\[\e[36m\]\u@\h:\W\[\e[0m\] $ '
98 '';
99
100 programs.gpg = {
101 enable = true;
102 publicKeys = [
103 {
104 text = ''
105 -----BEGIN PGP PUBLIC KEY BLOCK-----
106
107 mDMEZZ1zrBYJKwYBBAHaRw8BAQdA8Zeb1OFbzEWx3tM7ylO0ILCnDCG2JoA/iay6
108 iWXmB7G0G1J5YW4gR2liYiA8cnlhbkBmcmV1bWgub3JnPoiUBBMWCgA8FiEE67lV
109 Y2amyVrqUoWjGfnbY35Mq3QFAmWdc6wCGwMFCQPCZwAECwkIBwQVCgkIBRYCAwEA
110 Ah4FAheAAAoJEBn522N+TKt0mwcA/AvuKD4dTPj4hJ/cezEWDOFELMaVYZqDS3V1
111 LmRJrdIHAQDYgST8awabyd2Y3PRTFf9ZcWRRompeg0v7c2hCc9/3A7g4BGWdc6wS
112 CisGAQQBl1UBBQEBB0AdJP8T3mGR7SUp9DBlIaVU1ESRC7sLWbm4QFCR1JTfSgMB
113 CAeIfgQYFgoAJhYhBOu5VWNmpsla6lKFoxn522N+TKt0BQJlnXOsAhsMBQkDwmcA
114 AAoJEBn522N+TKt07KwA/10R+ejRZeW0cYScowHAsnDZ09A43bZvdp1X7KeQHMl+
115 AQD+TbceHh393VFc4tkl5pYHfrmkCXMdN0faVWolkc7GCA==
116 =EfP/
117 -----END PGP PUBLIC KEY BLOCK-----
118 '';
119 trust = "ultimate";
120 }
121 ];
122 };
123 services.gpg-agent.pinentryPackage = pkgs.pinentry-qt;
124
125 programs.git = {
126 enable = true;
127 extraConfig = {
128 init = {
129 defaultBranch = "main";
130 };
131 user = {
132 email = "ryan@freumh.org";
133 name = "Ryan Gibb";
134 signingKey = "19F9DB637E4CAB74";
135 };
136 alias = {
137 s = "status";
138 c = "commit";
139 cm = "commit --message";
140 ca = "commit --amend";
141 cu = "commit --message update";
142 ci = "commit --message initial";
143 br = "branch";
144 co = "checkout";
145 df = "diff";
146 l = "log";
147 lg = "log -p";
148 lol = "log --graph --decorate --pretty=oneline --abbrev-commit";
149 lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all";
150 ls = "ls-files";
151 a = "add";
152 aa = "add --all";
153 au = "add -u";
154 ap = "add --patch";
155 ai = "add -i";
156 ps = "push";
157 pf = "push --force";
158 pu = "push --set-upstream";
159 pl = "pull";
160 pr = "pull --rebase";
161 acp = "!git add --all && git commit --message update && git push";
162 d = "diff";
163 dc = "diff --cached";
164 };
165 };
166 };
167
168 programs.tmux = {
169 enable = true;
170 extraConfig =
171 let
172 toggle-status-bar = pkgs.writeScript "toggle-status-bar.sh" ''
173 #!/usr/bin/env bash
174 window_count=$(tmux list-windows | wc -l)
175 if [ "$window_count" -ge "2" ]; then
176 tmux set-option status on
177 else
178 tmux set-option status off
179 fi
180 '';
181 # https://github.com/ThePrimeagen/.dotfiles/blob/master/bin/.local/scripts/tmux-sessionizer
182 sessionizer = pkgs.writeScript "sessionizer.sh" ''
183 #!/usr/bin/env bash
184
185 if [[ $# -eq 1 ]]; then
186 selected=$1
187 else
188 selected=$(find ~ -not -path '*/.*' -maxdepth 2 -type d | fzf)
189 fi
190
191 if [[ -z $selected ]]; then
192 exit 0
193 fi
194
195 selected_name=$(basename "$selected" | tr . _)
196 tmux_running=$(pgrep tmux)
197
198 if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
199 tmux new-session -s $selected_name -c $selected
200 exit 0
201 fi
202
203 if ! tmux has-session -t=$selected_name 2> /dev/null; then
204 tmux new-session -ds $selected_name -c $selected
205 fi
206
207 tmux switch-client -t $selected_name
208 '';
209 in
210 ''
211 # alternative modifier
212 unbind C-b
213 set-option -g prefix C-a
214 bind-key C-a send-prefix
215
216 set-window-option -g mode-keys vi
217 set-option -g mouse on
218 set-option -g set-titles on
219 set-option -g set-titles-string "#T"
220 bind-key t capture-pane -S -\; new-window '(tmux show-buffer; tmux delete-buffer) | nvim -c $'
221 bind-key u capture-pane\; new-window '(tmux show-buffer; tmux delete-buffer) | ${pkgs.urlscan}/bin/urlscan'
222 set-hook -g session-window-changed 'run-shell ${toggle-status-bar}'
223 set-hook -g session-created 'run-shell ${toggle-status-bar}'
224 # Fixes C-Up/Down in TUIs
225 set-option default-terminal tmux
226 # https://stackoverflow.com/questions/62182401/neovim-screen-lagging-when-switching-mode-from-insert-to-normal
227 # locking
228 set -s escape-time 0
229 set -g lock-command ${pkgs.vlock}/bin/vlock
230 set -g lock-after-time 0 # Seconds; 0 = never
231 bind L lock-session
232 # for .zprofile display environment starting https://github.com/tmux/tmux/issues/3483
233 set-option -g update-environment XDG_VTNR
234 # Allow clipboard with OSC-52 work
235 set -s set-clipboard on
236 # toggle
237 bind -r ^ last-window
238 # vim copy
239 bind -T copy-mode-vi v send-keys -X begin-selection
240 bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel
241 # find
242 bind-key -r g run-shell "tmux neww ${sessionizer}"
243 # reload
244 bind-key r source-file ~/.config/tmux/tmux.conf
245 # kill unattached
246 bind-key K run-shell 'tmux ls | grep -v attached | cut -d: -f1 | xargs -I {} tmux kill-window -t {}'
247 '';
248 };
249
250 programs.less = {
251 enable = true;
252 keys = ''
253 #line-edit
254 \e[1;5D word-left
255 \e[1;5C word-right
256 '';
257 };
258
259 programs.go.goPath = "~/.go";
260
261 home.stateVersion = "22.05";
262 };
263}