nix config
1{ lib, pkgs, config, ... }:
2{
3 home.packages = with pkgs; [
4 # unstable.claude-code
5 binutils
6 # coreutils
7 dnsutils
8 dasht
9 dosfstools
10 # git
11 git-machete
12 git-spice
13 # jujitsu
14 asciinema
15 bottom
16 gptfdisk
17 starship
18 # TODO Not available on Darwin
19 # iputils
20 # usbutils
21 # cached-nix-shell
22 # utillinux
23 # strace
24 # mtr
25 # gdb
26 # fontconfig
27 # whois
28
29 # jq
30 manix
31 moreutils
32 nix-index
33 nmap
34 ripgrep
35 skim
36 tealdeer
37 iftop
38 wget
39 curl
40 eza
41 bat
42 fd
43 ncdu
44 du-dust
45 # dia-cli
46 duf
47 trash-cli
48 nix-index
49 silver-searcher
50 tcpdump
51 file
52 lsof
53 atool
54 zip
55 unzip
56 rsync
57 tmux
58 pwgen
59 glow
60 pass
61 less
62 xxd
63 taskwarrior
64 gnupg
65 syncthing
66 dijo
67 # ssb-patchwork
68 pandoc
69 taskwarrior-tui
70 zk
71 diffnav
72
73 # llms (needs 24.11)
74 aider-chat
75
76 (pkgs.writeScriptBin "jq-repl" ''
77 #!/usr/bin/env bash
78 if [[ -z $1 ]] || [[ $1 == "-" ]]; then
79 input=$(mktemp)
80 trap "rm -f $input" EXIT
81 cat /dev/stdin > $input
82 else
83 input=$1
84 fi
85
86 echo "" \ | fzf --phony --preview-window="up:90%" --print-query --preview "jq --color-output -r {q} $input"
87 '')
88 (pkgs.writeScriptBin "clear-vim-trash" (builtins.readFile ./bin/clear-vim-trash.sh))
89 (pkgs.writeScriptBin "flakify" ''
90 #!/usr/bin/env zsh
91 if [ ! -e flake.nix ]; then
92 nix flake new -t github:nix-community/nix-direnv .
93 elif [ ! -e .envrc ]; then
94 echo "use flake" > .envrc
95 direnv allow
96 fi
97 vim flake.nix
98 '')
99 (pkgs.writeScriptBin "mx" ''
100 #!/usr/bin/env bash
101 manix "" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | fzf --preview="manix '{}'" | xargs manix
102 '')
103 (pkgs.writeScriptBin "monitor" ''
104 # hotplug
105 connect() {
106 # Turn it on if it was off
107 xrandr --output HDMI-2 --auto
108 xrandr --output HDMI-2 --same-as eDP-1
109 }
110
111 disconnect() {
112 xrandr --output HDMI-2 --off
113 }
114
115 xrandr | grep "HDMI-2 connected" &>>/dev/null && connect || disconnect
116 '')
117 (pkgs.writeScriptBin "disconnect-keyboard" ''
118 # keyboard on curve is busted
119 get_keyboard_id() {
120 xinput list | grep 'AT Translated Set' | cut -f2 | cut -d'=' -f2 | xinput float
121 }
122
123 disconnect_keyboard() {
124 id=$(get_keyboard_id)
125 xinput float $id
126 unset id
127 }
128
129 attach_keyboard() {
130 id=$(get_keyboard_id)
131 xinput reattach $id 3
132 unset id
133 }
134
135 disconnect_keyboard
136 '')
137 ];
138
139 programs.zsh = {
140 enable = true;
141 enableCompletion = true;
142 autosuggestion.enable = false;
143
144 initExtra = ''
145 autopair-init
146 '';
147 sessionVariables = {
148 EDITOR = "nvim";
149 TERMINFO_DIRS = "${pkgs.kitty.terminfo.outPath}/share/terminfo"; # Needed to run home-manager switch on non-nixOS
150 };
151 plugins = [
152 {
153 name = "zsh-autopair";
154 src = pkgs.fetchFromGitHub {
155 owner = "hlissner";
156 repo = "zsh-autopair";
157 rev = "34a8bca0c18fcf3ab1561caef9790abffc1d3d49";
158 sha256 = "1h0vm2dgrmb8i2pvsgis3lshc5b0ad846836m62y8h3rdb3zmpy1";
159 };
160 file = "autopair.zsh";
161 }
162 {
163 name = "zsh-syntax-highlighting";
164 src = pkgs.fetchFromGitHub {
165 owner = "zsh-users";
166 repo = "zsh-syntax-highlighting";
167 rev = "0.6.0";
168 sha256 = "0zmq66dzasmr5pwribyh4kbkk23jxbpdw4rjxx0i7dx8jjp2lzl4";
169 };
170 file = "zsh-syntax-highlighting.zsh";
171 }
172 {
173 name = "zsh-autoquoter";
174 src = pkgs.fetchFromGitHub {
175 owner = "ianthehenry";
176 repo = "zsh-autoquoter";
177 rev = "819a615fbfd2ad25c5d311080e3a325696b45de7";
178 sha256 = "r0jdo+YFTOejvNMTqzXi5ftcLzDpuKejX0wMFwqKdJY=";
179 };
180 file = "zsh-autoquoter.zsh";
181 }
182 # {
183 # name = "zsh-nix-shell";
184 # file = "nix-shell.plugin.zsh";
185 # src = pkgs.fetchFromGitHub {
186 # owner = "chisui";
187 # repo = "zsh-nix-shell";
188 # rev = "v0.5.0";
189 # sha256 = "0za4aiwwrlawnia4f29msk822rj9bgcygw6a8a6iikiwzjjz0g91";
190 # };
191 # }
192 ];
193 };
194
195 programs.starship = {
196 enable = true;
197 enableZshIntegration = true;
198 };
199
200 programs.fzf = {
201 enable = true;
202 enableZshIntegration = true;
203 };
204
205 programs.direnv = {
206 enable = true;
207 enableZshIntegration = true;
208 nix-direnv.enable = true;
209 };
210
211 programs.zoxide = {
212 enable = true;
213 enableZshIntegration = true;
214 };
215
216 # Only available on Linux
217 # services.kdeconnect.enable = true;
218
219 home.shellAliases = {
220 # quick cd
221 ".." = "cd ..";
222 "..." = "cd ../..";
223 "...." = "cd ../../..";
224 "....." = "cd ../../../..";
225
226 icat = "kitty +kitten icat";
227 yt = "ytfzf -T kitty -t ";
228 gen-secret = "< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c\${1:-32};echo;";
229
230 # modern cli tools
231 ls = "eza --icons";
232 l = "esa -l --icons";
233 la = "eza -la --icons";
234 tree = "ls --tree --icons";
235 cat = "bat";
236 unzip = "aunpack";
237 copy = "xclip -selection clipboard";
238 paste = "xclip -selection clipboard -o";
239 rm = "echo USE TRASH, FOOL: trash ";
240 trash = "trash-put";
241 make-secret = "< /dev/urandom \\tr -dc _A-Za-z0-9 | head -c \${1:-32};echo;";
242
243 # task warrior
244 t = "task -BLOCKED -idea -backlog";
245 tw = "t rc.context:work";
246 # TODO find a reasonable way to manage this from a non-nix managed file in ~/.task/context or something
247 # we can do something like task rc.context:$(cat ~/.task/context) to read context
248 # and write a little script make-context = cat $@ > ~/.task/context or something
249 tt = "taskwarrior-tui -r list";
250 ti = "task +idea";
251 tb = "task +backlog list";
252 ttb = "taskwarrior-tui -r backlog";
253 tr = "task newest limit:page";
254 twait = "task +wait";
255 ta = "task add";
256 tai = "task add +idea";
257 tn = "task-note";
258 ts = "task sync";
259 # taskwarrior task lists
260 twt = "task tags +PENDING | tail -n +4 | cut -d ' ' -f1 | fzf --preview 'task +{}'";
261 # task warrior projects list
262 tp = "task projects +PENDING | tail -n +4 | head -n -2 | cut -d ' ' -f1 | fzf --preview 'task pro:{}'";
263
264 # keeping for posterity but now sxhkbd handles screenshot with <Super+O>
265 # scrot = "flameshot screen -c -p ~/screenshots/";
266 # scrotgui = "flameshot gui -p ~/screenshots/";
267
268 # git
269 g = "git";
270 gl = "git log --pretty=oneline --abbrev-commit";
271
272 # grep
273 grep = "rg";
274 gi = "grep -i";
275
276 # internet ip
277 myip = "dig +short myip.opendns.com @208.67.222.222 2>&1";
278
279 # nix
280 n = "nix";
281 np = "n profile";
282 ni = "np install";
283 nr = "np remove";
284 ns = "n search --no-update-lock-file";
285 nf = "n flake";
286 nfl = "nf lock";
287 nepl = "n repl '<nixpkgs>'";
288 srch = "ns nixpkgs";
289 orch = "ns override";
290 nrb = "cd /tmp; sudo nixos-rebuild switch --flake '/home/anish/usr/helm#curve'; cd $OLDPWD";
291 nrd = "cd /tmp; NIXPKGS_ALLOW_UNFREE=1 darwin-rebuild switch --flake /Users/anishlakhwara/usr/helm#Anishs-MacBook-Pro --impure; cd $OLDPWD";
292 nrt = "cd /tmp; sudo nixos-rebuild test --flake '/home/anish/usr/helm#curve'; cd $OLDPWD";
293 ned = "cd /home/anish/usr/helm; vim; cd $OLDPWD";
294 ncd = "cd /home/anish/usr/helm";
295 mn = ''
296 manix "" | grep '^# ' | sed 's/^# \(.*\) (.*/\1/;s/ (.*//;s/^# //' | sk --preview="manix '{}'" | xargs manix
297 '';
298
299 # sudo
300 s = "sudo -E ";
301 pls = "s";
302 si = "sudo -i";
303 se = "sudoedit";
304
305 # top
306 top = "btm";
307
308 # systemd
309 ctl = "systemctl";
310 stl = "s systemctl";
311 utl = "systemctl --user";
312 ut = "systemctl --user start";
313 un = "systemctl --user stop";
314 up = "s systemctl start";
315 dn = "s systemctl stop";
316 jtl = "journalctl";
317
318 # quick ssh
319 kssh = "kitty +kitten ssh";
320 smm = "ssh 10.0.69.4"; # box over wireguard
321 sm = "ssh mossnet.lan"; # box regular
322 sl = "ssh sealight.xyz"; # lituus
323 sh = "ssh git.sealight.xyz"; # helix
324 sb = "ssh cyberian@69.61.38.246"; # bonfire for allwell
325 };
326}