-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.nix
More file actions
309 lines (268 loc) · 8.62 KB
/
home.nix
File metadata and controls
309 lines (268 loc) · 8.62 KB
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
{ config, pkgs, ... }:
{
home.username = "json0";
home.homeDirectory = "/home/json0";
home.stateVersion = "23.11";
home.packages = with pkgs; [
# --- Core Utilities ---
fzf
ripgrep
fd
bat
jq
htop
btop
tree
gcc
gnumake
wl-kbptr
wlrctl
ack
# --- Network monitoring ---
bandwhich
nethogs
tcpdump
nmap
termshark
trippy
dog
# --- Git & Version Control ---
git
lazygit
commitizen
# --- Terminal Workspace ---
# tmux is installed via programs.tmux below
ranger
# --- Editors & Note Taking ---
neovim
newsboat
# --- Development & Infrastructure ---
go
python3
uv
nodejs
kubectl
k9s
helm
opentofu
rustup
aider-chat
ollama
github-cli
# --- Input remapping ---
xremap
];
systemd.user.services.ollama = {
Unit = {
Description = "Ollama Local LLM Runner";
After = [ "network.target" ];
};
Service = {
ExecStart = "${pkgs.ollama}/bin/ollama serve";
Restart = "always";
};
Install = {
WantedBy = [ "default.target" ];
};
};
programs.bash = {
enable = true;
shellAliases = {
v = "nvim";
vim = "nvim";
g = "git";
lg = "lazygit";
r = "ranger";
cdd = "cd ~/Documents/workarea/dotfiles";
cdw = "cd ~/Documents/workarea";
alerts = "sudo ~/bin/suricata-alerts.sh";
sniff = "sudo \"$(which bandwhich)\"";
capture = "sudo tcpdump -i any -w /tmp/capture-$(date +%s).pcap";
shark = "termshark";
};
initExtra = ''
# Pull in home-manager session vars (PATH, EDITOR, …) for non-login interactive
# shells too — .profile is only sourced by login shells.
if [ -f ~/.nix-profile/etc/profile.d/hm-session-vars.sh ]; then
. ~/.nix-profile/etc/profile.d/hm-session-vars.sh
fi
# Better History: ignore duplicates and space-started commands
export HISTCONTROL=ignoreboth:erasedups
export HISTSIZE=10000
export HISTFILESIZE=20000
# Autocomplete cd: typing a directory name moves you there
shopt -s autocd
# Correct minor directory typos
shopt -s cdspell
# Source your specific completion scripts
if [ -f ~/.completions/tmux_kube.sh ]; then
source ~/.completions/tmux_kube.sh
fi
# --- Prompt ---
__git_branch() {
git symbolic-ref --short HEAD 2>/dev/null
}
__prompt_command() {
local exit_code=$?
PS1=""
# Red ✗ only on non-zero exit
if [ $exit_code -ne 0 ]; then
PS1+="\[\e[31m\]✗ \[\e[0m\]"
fi
# Working directory (basename only) — gruvbox gray (palette colour 7, #a89984)
PS1+="\[\e[37m\]\W\[\e[0m\]"
# Git branch (only when in a repo)
local branch
branch=$(__git_branch)
if [ -n "''${branch}" ]; then
PS1+=" \[\e[33m\]''${branch}\[\e[0m\]"
fi
PS1+=" \$ "
}
PROMPT_COMMAND=__prompt_command
'';
};
programs.fzf = {
enable = true;
enableBashIntegration = true;
defaultOptions = [
"--height 40%"
"--layout=reverse"
"--border"
"--inline-info"
"--color=bw"
];
defaultCommand = "fd --type f";
fileWidgetCommand = "fd --type f";
};
programs.tmux = {
enable = true;
prefix = "C-a";
keyMode = "vi";
baseIndex = 1;
escapeTime = 10;
historyLimit = 50000;
mouse = true;
focusEvents = true;
aggressiveResize = true;
clock24 = true;
terminal = "tmux-256color";
# tmux-sensible is prepended automatically (sensibleOnTop).
# The remaining plugins are installed by Nix — no TPM. They are
# appended *after* the readFile content so that settings like
# @resurrect-* and the battery status-right tokens are already
# in place when each plugin loads (home-manager's own `plugins`
# option would load them too early).
extraConfig = builtins.readFile ./tmux/tmux.conf + ''
# ── Plugins (installed by Nix) ────────────────────────────
run-shell ${pkgs.tmuxPlugins.resurrect.rtp}
run-shell ${pkgs.tmuxPlugins.continuum.rtp}
run-shell ${pkgs.tmuxPlugins.vim-tmux-navigator.rtp}
run-shell ${pkgs.tmuxPlugins.battery.rtp}
# vim-tmux-navigator binds C-h/j/k/l for pane navigation, which
# steals C-l (clear screen). Reclaim it — must come *after* the
# plugin's run-shell. Navigate right with M-l or prefix+l.
unbind -n C-l
'';
};
home.file = {
# Neovim (LazyVim) - Out-of-store symlink so it can write to lazy-lock.json
".config/nvim".source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/Documents/workarea/dotfiles/nvim";
".config/ranger/rc.conf".source = ./ranger/rc.conf;
".config/lazygit/config.yml".source = ./lazygit/config.yml;
".config/sway/config".source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/Documents/workarea/dotfiles/sway/config";
".config/sway/cheatsheet.sh".source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/Documents/workarea/dotfiles/sway/cheatsheet.sh";
".config/sway/powermenu.sh".source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/Documents/workarea/dotfiles/sway/powermenu.sh";
# Sourced from the local-config private repo (sibling of dotfiles).
# Run `make local-sync` to clone or update it before `make hm`.
".claude/settings.json".source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/Documents/workarea/local-config/settings.json";
".claude/hooks".source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/Documents/workarea/local-config/hooks";
".config/swaylock/config".source = ./swaylock/config;
".config/wofi/config".source = ./wofi/config;
".config/wofi/style".source = ./wofi/style.css;
".config/ghostty/config".source = ./ghostty/config;
".config/mako/config".source = ./mako/config;
".config/waybar/config".source = ./waybar/config;
".config/waybar/style.css".source = ./waybar/style.css;
".newsboat/config".source = ./newsboat/config;
".newsboat/urls".source = ./newsboat/urls;
# Custom scripts
"bin/connection-checker.py".source = ./bin/connection-checker/connection-checker.py;
"bin/diagnosis.sh".source = ./bin/debug/fedora_diagnosis.sh;
"bin/view.py".source = ./bin/wakatime-view/view.py;
# Suricata scripts
"bin/suricata-alerts.sh".source = ./bin/suricata/suricata-alerts.sh;
"bin/suricata-watcher.sh".source = ./bin/suricata/suricata-watcher.sh;
"bin/suricata-notify.sh".source = ./bin/suricata/suricata-notify.sh;
".config/xremap/config.yml".source = ./xremap/config.yml;
# Force GTK4's GL renderer for Fractal — Vulkan-on-Nvidia produces a blank window.
".local/share/flatpak/overrides/org.gnome.Fractal".source =
./flatpak/overrides/org.gnome.Fractal;
};
home.sessionVariables = {
EDITOR = "nvim";
VISUAL = "nvim";
GIT_EDITOR = "nvim";
};
home.sessionPath = [
"$HOME/.cargo/bin"
"$HOME/.local/bin"
];
# Suricata real-time alert watcher
systemd.user.services.suricata-watcher = {
Unit = {
Description = "Suricata real-time alert watcher";
After = [ "graphical-session.target" ];
PartOf = [ "graphical-session.target" ];
};
Service = {
Type = "simple";
ExecStart = "%h/bin/suricata-watcher.sh";
Restart = "on-failure";
RestartSec = 30;
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
};
# Hourly alert summary
systemd.user.services.suricata-notify = {
Unit = {
Description = "Suricata hourly alert check";
};
Service = {
Type = "oneshot";
ExecStart = "%h/bin/suricata-notify.sh";
};
};
systemd.user.timers.suricata-notify = {
Unit = {
Description = "Hourly Suricata alert check";
};
Timer = {
OnCalendar = "hourly";
RandomizedDelaySec = 120;
Persistent = true;
};
Install = {
WantedBy = [ "timers.target" ];
};
};
systemd.user.services.xremap = {
Unit = {
Description = "xremap key remapper";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${pkgs.xremap}/bin/xremap %h/.config/xremap/config.yml";
Restart = "on-failure";
RestartSec = 5;
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
};
# Let Home Manager manage itself
programs.home-manager.enable = true;
}