-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.nix
465 lines (425 loc) · 15.2 KB
/
home.nix
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
{ home-manager, nixvim, dactylogramme, pkgs, lib, username, stateVersion, ... } : {
imports = [ home-manager.nixosModules.home-manager ];
# Use NixOS nixpkgs & configurations
home-manager.useGlobalPkgs = true;
# Install packages in /etc/profiles
home-manager.useUserPackages = true;
# zogstrip's group
users.groups.${username} = {};
# zogstrip's user account
users.users.${username} = {
# Just a regular user
isNormalUser = true;
# `mkpasswd -m yescrypt > /persist/passwd` to generate hash
hashedPassword = "";
# TODO: hashedPasswordFile = "/persist/passwd";
# Set the `zogstrip` group
group = username;
# Other groups
extraGroups = [
"networkmanager" # wifi
"video" # brightness
"wheel" # sudo
];
};
# Programs installed from NixOS rather than Home Manager
# 1Password GUI & CLI
programs._1password.enable = true;
programs._1password-gui.enable = true;
programs._1password-gui.polkitPolicyOwners = [ username ];
# nh os switch (has much better output)
programs.nh.enable = true;
programs.nh.flake = "/persist/z/poetry/config";
# disable command-not-found
programs.command-not-found.enable = false;
environment.systemPackages = [
# https://github.com/ZogStriP/dactylogramme/
dactylogramme.packages.${pkgs.system}.default
];
# zogstrip's home configuration
home-manager.users.${username} = {
imports = [ nixvim.homeManagerModules.nixvim ];
home.username = username;
home.homeDirectory = "/home/${username}";
# Sync home manager's version with NixOS'
home.stateVersion = stateVersion;
# Some shell aliases
home.shellAliases = {
".." = "cd ..";
"..." = "cd ../..";
"ff" = "fastfetch";
};
# Programs that don't need configuration
home.packages = with pkgs; [
curl # making requests
devenv # https://devenv.sh
duf # better `df`
dust # better `du`
jless # JSON pager
ncdu # interactive `du`
wget # downloading stuff
wl-clipboard # wl-copy / wl-paste
zeal # offline doc
];
# Configure dark mode for GTK3 applications
gtk.enable = true;
gtk.gtk3.extraConfig.gtk-application-prefer-dark-theme = true;
# Configure dark mode for Qt applications
qt.enable = true;
qt.style.name = "adwaita-dark";
# Programs that need configuration
programs = {
# Let home manager manage itself
home-manager.enable = true;
# enable bash (for TTYs)
bash.enable = true;
# automatically launch `river` on tty1
bash.profileExtra = ''
[[ -z "$DISPLAY" && $(tty) = "/dev/tty1" ]] && exec ${pkgs.river}/bin/river > ~/.river.log 2>&1
'';
# enable fish (used in `foot`)
fish.enable = true;
# configure fish
fish.interactiveShellInit = ''
# disable greeting
set fish_greeting
# run on each prompt
function on_prompt --on-event fish_prompt
# marker to allow jumping between prompt (ctrl+shift+y / ctrl+shift+x)
echo -en "\e]133;A\e\\"
# save last dir
echo $PWD > ~/.last
end
# cd into last dir
if test -f ~/.last
cd (cat ~/.last)
end
'';
# enable starship prompt
starship.enable = true;
# enable direnv
direnv.enable = true;
# silence direnv
direnv.silent = true;
# ssh
ssh.enable = true;
# use compression
ssh.compression = true;
# use 1password SSH agent
ssh.matchBlocks."*".extraOptions.IdentityAgent = "~/.1password/agent.sock";
# source control
git = {
enable = true;
# use difftastic for better diffing
difftastic.enable = true;
# git aliases
aliases = {
b = "branch";
br = "branch";
co = "checkout";
st = "status";
wip = "!f() { git add .; git commit --no-verify -m 'wip'; }; f";
undo = "reset HEAD~1 --mixed";
};
# global git config
extraConfig = {
init.defaultBranch = "main";
push.autoSetupRemote = true;
# always use SSH - https://www.jvt.me/posts/2019/03/20/git-rewrite-url-https-ssh/
url."ssh://[email protected]/".InsteadOf = "https://github.com/";
# commit signing
commit.gpgsign = true;
gpg.format = "ssh";
gpg.ssh.program = lib.getExe' pkgs._1password-gui "op-ssh-sign";
# user settings
user = {
name = username;
email = "[email protected]";
signingKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO3naLkQYJ4SP6pk/ZoPWJcUW4hoOoBzy1JoO8I5lpze";
};
};
};
# (wayland) terminal emulator
# https://codeberg.org/dnkl/foot
foot.enable = true;
foot.settings = {
# black background
colors.background = "000000";
# bigger font
main.font = "monospace:size=12";
# default shell
main.shell = "fish";
# hide mouse when typing
mouse.hide-when-typing = true;
# lots of scrollback (default is 1k)
scrollback.lines = 65536;
};
# system informations (better `neofetch`)
fastfetch.enable = true;
# text editor
# monochrome theme from https://wickstrom.tech/2024-08-12-a-flexible-minimalist-neovim.html
nixvim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
colorscheme = "quiet";
# TODO: find a way to use 'nix' to configure these?
extraConfigVim = ''
highlight Keyword gui=bold
highlight Comment gui=italic
highlight Constant guifg=#999999
highlight NormalFloat guibg=#333333
'';
opts = {
# show current line number
number = true;
# show relative numbers
relativenumber = true;
# convert spaces to tabs
expandtab = true;
# 2 spaces for each "indent"
shiftwidth = 2;
# 2 spaces for <tab> or <del>
softtabstop = 2;
# case insensitive search by default
ignorecase = true;
# case sensitive search only when there's an uppercase character
smartcase = true;
# disable wrapping by default
wrap = false;
# merge both * and + registers to allow system-wide copy/paste
clipboard = "unnamedplus";
};
};
# json tooling
jq.enable = true;
# web browser
firefox.enable = true;
firefox.policies = {
DisableAccounts = true;
ExtensionSettings = {
# 1Password:
"{d634138d-c276-4fc8-924b-40a0ea21d284}" = {
install_url = "https://addons.mozilla.org/firefox/downloads/latest/1password-x-password-manager/latest.xpi";
installation_mode = "force_installed";
};
# uBlock Origin:
"[email protected]" = {
install_url = "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi";
installation_mode = "force_installed";
};
};
};
firefox.profiles.${username} = {
id = 0;
name = username;
settings = {
"app.normandy.api_url" = "";
"app.normandy.enabled" = false;
"app.shield.optoutstudies.enabled" = true;
"apz.gtk.kinetic_scroll.enabled" = false;
"browser.aboutConfig.showWarning" = false;
"browser.discovery.enabled" = false;
"browser.newtabpage.activity-stream.discoverystream.enabled" = false;
"browser.newtabpage.enabled" = false;
"browser.region.network.url" = "";
"browser.region.update.enabled" = false;
"browser.startup.blankWindow" = true;
"browser.startup.firstrunSkipsHomepage" = true;
"browser.startup.homepage" = "about:blank";
"browser.toolbars.bookmarks.visibility" = "never";
"browser.topsites.contile.enabled" = false;
"browser.topsites.contile.endpoint" = "";
"browser.translations.automaticallyPopup" = false;
"browser.urlbar.suggest.searches" = false;
"browser.urlbar.suggest.topsites" = false;
"browser.urlbar.suggest.trending" = false;
"browser.urlbar.suggest.weather" = false;
"browser.urlbar.suggest.yelp" = false;
"datareporting.healthreport.uploadEnabled" = false;
"datareporting.policy.dataSubmissionEnabled" = false;
"datareporting.policy.firstRunURL" = "";
"dom.push.connection.enabled" = false;
"extensions.pocket.enabled" = false;
"privacy.donottrackheader.enabled" = true;
"privacy.globalprivacycontrol.enabled" = true;
"startup.homepage_welcome_url" = "about:blank";
};
};
# better `ls`
eza.enable = true;
# display icons
eza.icons = "auto";
# better `cd`
zoxide.enable = true;
# better `top`
btop.enable = true;
btop.settings = {
# set refresh rate to 1s
update_ms = 1000;
# show processes as a tree
proc_tree = true;
# only show these "disks"
disks_filter = "/ /boot /nix /tmp /swap";
# use hjkl to navigate
vim_keys = true;
# square corners look better
rounded_corners = false;
};
# better `cat`
bat.enable = true;
# better `grep`
ripgrep.enable = true;
# better `find`
fd.enable = true;
# spotify player
spotify-player.enable = true;
};
# (wayland) window manager
# https://isaacfreund.com/software/river/
# TODO: compare the following modules
# - https://github.com/nix-community/home-manager/blob/master/modules/services/window-managers/river.nix
# - https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/programs/wayland/river.nix
wayland.windowManager.river = {
# enable `river` wm
enable = true;
# DOC: https://codeberg.org/river/river/src/branch/master/doc/riverctl.1.scd
# TUTO: https://leon_plickat.srht.site/writing/river-setup-guide/article.html
# EXAMPLE: https://codeberg.org/river/river/src/branch/master/example/init
settings = {
# black background
background-color = "0x000000";
# use `rivertile` for layout
default-layout = "rivertile";
# define Right-Alt to be Compose key
keyboard-layout."-variant".altgr-intl."-options"."compose:rwin" = "us";
# faster keyboard repeat <rate> (25/s) <delay> (600ms)
set-repeat = "20 150";
# enable natural scrolling on touchpad
input."*_Touchpad".natural-scroll = true;
# remove borders
border-width = 0;
# keyboard shortcuts
map.normal = {
###
### Function keys
###
# (F1) Mute
"None XF86AudioMute" = "spawn 'wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle'";
# (F2) Lower volume
"None XF86AudioLowerVolume" = "spawn 'wpctl set-volume @DEFAULT_AUDIO_SINK@ 3%-'";
# (F3) Raise volume (maximum 100%)
"None XF86AudioRaiseVolume" = "spawn 'wpctl set-volume @DEFAULT_AUDIO_SINK@ 3%+ --limit 1'";
# (F4) TODO: Previous
# "None XF86AudioPrev" = "spawn ''";
# (F5) TODO: Play/Pause
# "None XF86AudioPlay" = "spawn ''";
# (F6) TODO: Next
# "None XF86AudioNext" = "spawn ''";
# (F7) Brightness down
"None XF86MonBrightnessDown" = "spawn 'xbacklight -2 -perceived'";
# (F8) Brightness up
"None XF86MonBrightnessUp" = "spawn 'xbacklight +2 -perceived'";
# (F9) <not used>
# (F10) Plane mode
# "None XF86RFKill" = "spawn 'rfkill toggle wlan'";
# (F11) TODO: <print screen>
# (F12) <not used>
###
### Regular shortcuts
###
# open new terminal
"Super Return" = "spawn foot";
# open firefox
"Super F" = "spawn firefox";
# open 1Password's quick access
"Super P" = "spawn '1password --quick-access'";
# open 1Password
"Super+Shift P" = "spawn '1password --toggle'";
# open zeal
"Super Z" = "spawn zeal";
# close focused view
"Super Q" = "close";
# disable Ctrl+Q shortcut
"Control Q" = "none";
# exit `river`
"Super+Shift E" = "exit";
###
### Tag management
###
# show 'workspace' X
"Super 1" = "set-focused-tags 1";
"Super 2" = "set-focused-tags 2";
"Super 3" = "set-focused-tags 4";
"Super 4" = "set-focused-tags 8";
# send <focused view> to 'workspace' X
"Super+Shift 1" = "set-view-tags 1";
"Super+Shift 2" = "set-view-tags 2";
"Super+Shift 3" = "set-view-tags 4";
"Super+Shift 4" = "set-view-tags 8";
# bring 'workspace' X into view
"Super+Alt 1" = "toggle-focused-tags 1";
"Super+Alt 2" = "toggle-focused-tags 2";
"Super+Alt 3" = "toggle-focused-tags 4";
"Super+Alt 4" = "toggle-focused-tags 8";
###
### Window management
###
# focus views
"Super H" = "focus-view left";
"Super J" = "focus-view down";
"Super K" = "focus-view up";
"Super L" = "focus-view right";
"Super BracketLeft" = "focus-view previous";
"Super BracketRight" = "focus-view next";
# Toggle float (on focused view)
"Super+Shift F" = "toggle-float";
# swap focus
"Super+Shift H" = "swap left";
"Super+Shift J" = "swap down";
"Super+Shift K" = "swap up";
"Super+Shift L" = "swap right";
"Super+Shift BracketLeft" = "swap previous";
"Super+Shift BracketRight" = "swap next";
# move floating views
"Super+Alt H" = "move left 50";
"Super+Alt J" = "move down 50";
"Super+Alt K" = "move up 50";
"Super+Alt L" = "move right 50";
# snap floating views
"Super+Alt+Control H" = "snap left";
"Super+Alt+Control J" = "snap down";
"Super+Alt+Control K" = "snap up";
"Super+Alt+Control L" = "snap right";
# resize floating views
"Super+Alt+Shift H" = "resize horizontal -50";
"Super+Alt+Shift J" = "resize vertical 50";
"Super+Alt+Shift K" = "resize vertical -50";
"Super+Alt+Shift L" = "resize horizontal 50";
###
### Layout management
###
"Super Left" = "send-layout-cmd rivertile 'main-ratio -0.05'";
"Super Right" = "send-layout-cmd rivertile 'main-ratio +0.05'";
};
# Add some rules based on "app-id"
rule-add."-app-id" = {
# ensures 1password is always floating
"1Password" = "float";
};
# launch some apps when starting
spawn = [
# layout manager
"'rivertile -view-padding 0 -outer-padding 0'"
# terminal emulator
"foot"
# 1password (background)
"'1password --silent'"
# polkit authentication agent
"dactylogramme"
];
};
};
};
}