-
Notifications
You must be signed in to change notification settings - Fork 0
/
dorphine-home.scm
432 lines (375 loc) · 14.4 KB
/
dorphine-home.scm
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
;; SPDX-FileCopyrightText: 2022, 2023, 2024 Hilton Chain <hako@ultrarare.space>
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
(define-module (dorphine-home)
#:use-module (blobs dorphine)
#:use-module (dorphine-emacs)
#:use-module (testament common)
#:use-module (testament counter-stop)
#:use-module (testament packages)
#:use-module (ice-9 format)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (guix download)
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (gnu home)
#:use-module (gnu home services)
#:use-module (gnu home services desktop)
#:use-module (gnu home services dotfiles)
#:use-module (gnu home services emacs)
#:use-module (gnu home services gnupg)
#:use-module (gnu home services guix)
#:use-module (gnu home services mcron)
#:use-module (gnu home services shells)
#:use-module (gnu home services sound)
#:use-module (gnu home services ssh)
#:use-module (gnu home services syncthing)
#:use-module (gnu packages admin)
#:use-module (gnu packages compression)
#:use-module (gnu packages fonts)
#:use-module (gnu packages freedesktop)
#:use-module (gnu packages gnome)
#:use-module (gnu packages gnome-xyz)
#:use-module (gnu packages gnupg)
#:use-module (gnu packages guile)
#:use-module (gnu packages image-viewers)
#:use-module (gnu packages linux)
#:use-module (gnu packages man)
#:use-module (gnu packages password-utils)
#:use-module (gnu packages qt)
#:use-module (gnu packages rsync)
#:use-module (gnu packages rust-apps)
#:use-module (gnu packages shellutils)
#:use-module (gnu packages ssh)
#:use-module (gnu packages terminals)
#:use-module (gnu packages tree-sitter)
#:use-module (gnu packages version-control)
#:use-module (gnu packages virtualization)
#:use-module (gnu packages wm)
#:use-module (gnu packages xdisorg)
#:use-module (gnu services)
#:use-module (gnu services mcron)
#:use-module (gnu system shadow)
#:use-module (rosenthal packages tree-sitter)
#:use-module (rosenthal packages wm))
;;
;; File-like
;;
(define %alacritty-theme-catppuccin-latte
(origin
(method url-fetch)
(uri (string-append "https://github.com/catppuccin/alacritty" "/raw/"
"832787d6cc0796c9f0c2b03926f4a83ce4d4519b"
"/catppuccin-latte.toml"))
(sha256
(base32 "09wvxg6vlfk4v47fildna1nxpjm88q6b7c6ig9xx1vyl5mpi8m51"))))
(define %config-alacritty
(let ((filename "alacritty.toml"))
(mixed-text-file
filename
"import = [ \"" %alacritty-theme-catppuccin-latte "\" ]\n"
(testament-file-content filename) "\n")))
(define %hyprland-switch-keyboard-layout
(program-file
"switch-keyboard-layout.scm"
(with-extensions (list guile-json-4)
#~(begin
(use-modules (ice-9 popen)
(json)
(rnrs io ports))
(define (get-keyboards)
(let* ((port (open-input-pipe
#$(file-append hyprland "/bin/hyprctl devices -j")))
(str (get-string-all port)))
(close-pipe port)
(assoc-ref (json-string->scm str) "keyboards")))
(define (get-layout)
(assoc-ref (vector-ref (get-keyboards) 0)
"active_keymap"))
(define keyboards
(get-keyboards))
(define layout
(if (string-contains (get-layout) "Dvorak")
1
0))
(for-each
(lambda (index)
(system* #$(file-append hyprland "/bin/hyprctl")
"switchxkblayout"
(assoc-ref (vector-ref keyboards index)
"name")
(number->string (- 1 layout))))
(iota (vector-length keyboards)))
(system* #$(file-append libnotify "/bin/notify-send")
(string-append "Layout: " (get-layout)))))))
(define %config-hyprland
(let ((filename "hyprland.conf")
(screenshot "~/Library/Pictures/Screenshots/$(date +%Y%m%d-%H%M%S).png")
(wallpaper (testament-file-object "96496968_p0.png"))
(lock-args #~(string-join
(list "--clock"
"--daemonize"
"--ignore-empty-password"
"--image"
#$(testament-file-object "115008128_p0.jpg"))))
(alacritty (file-append alacritty "/bin/alacritty"))
(grimblast (file-append grimblast "/bin/grimblast"))
(hyprctl (file-append hyprland "/bin/hyprctl"))
(light (file-append light "/bin/light"))
(mako (file-append mako "/bin/mako"))
(rofi (file-append rofi-wayland "/bin/rofi"))
(swaybg (file-append swaybg "/bin/swaybg"))
(swaylock (file-append swaylock-effects "/bin/swaylock"))
(wlsunset (file-append wlsunset "/bin/wlsunset"))
(wpctl (file-append wireplumber-minimal "/bin/wpctl"))
(xdp (file-append xdg-desktop-portal "/libexec/xdg-desktop-portal"))
(xdp-gtk (file-append xdg-desktop-portal-gtk "/libexec/xdg-desktop-portal-gtk"))
(xdp-hypr (file-append xdg-desktop-portal-hyprland "/libexec/xdg-desktop-portal-hyprland")))
(mixed-text-file
filename
(testament-file-content filename) "\n"
(apply string-append
(append-map
(match-lambda
((direction keys)
(map (lambda (key)
(format #f "~
bind=SUPER,~a,movefocus,~a~%"
key direction))
keys)))
'(("l" ("left"))
("d" ("down"))
("u" ("up"))
("r" ("right")))))
(apply string-append
(map (lambda (workspace-number)
(format #f "~
bind=SUPER,~a,workspace,~a
bind=SUPER SHIFT,~@*~a,movetoworkspace,~a~%"
workspace-number
(if (zero? workspace-number)
10
workspace-number)))
(iota 10)))
"bind=ALT,Tab,bringactivetotop\n"
"bind=ALT,Tab,cyclenext\n"
"bind=SUPER,Y,fullscreen\n"
"bind=SUPER,R,pseudo\n"
"bind=SUPER,period,togglefloating\n"
"bind=SUPER,C,togglesplit\n"
"bind=SUPER SHIFT,M,exit\n"
"bind=SUPER SHIFT,X,killactive\n"
;; Scroll through existing workspaces with SUPER + scroll.
"bind=SUPER,mouse_down,workspace,e-1\n"
"bind=SUPER,mouse_up,workspace,e+1\n"
;; Move/resize windows with SUPER + LMB/RMB and dragging.
"bindm=SUPER,mouse:272,movewindow\n"
"bindm=SUPER,mouse:273,resizewindow\n"
"monitor=,preferred,auto,auto\n"
"bindl=,switch:on:Lid Switch,exec," hyprctl " dispatch dpms off eDP-1\n"
"bindl=,switch:off:Lid Switch,exec," hyprctl " dispatch dpms on eDP-1\n"
"bind=SUPER,Return,exec,emacsclient --create-frame --no-wait --alternate-editor=''\n"
"bind=SUPER,space,exec," %hyprland-switch-keyboard-layout "\n"
"bind=SUPER,K,exec," alacritty "\n"
"bind=SUPER,O,exec," rofi " -modes combi -show combi -matching fuzzy\n"
"bind=SUPER,P,exec," swaylock " " lock-args "\n"
"bind=,Print,exec," grimblast " copysave output " screenshot "\n"
"bind=SUPER,Print,exec," grimblast " copysave area " screenshot "\n"
"bindl =,XF86AudioMicMute, exec," wpctl " set-mute @DEFAULT_AUDIO_SOURCE@ toggle\n"
"bindl =,XF86AudioMute, exec," wpctl " set-mute @DEFAULT_AUDIO_SINK@ toggle\n"
"bindle=,XF86AudioLowerVolume, exec," wpctl " set-volume @DEFAULT_AUDIO_SINK@ 5%-\n"
"bindle=,XF86AudioRaiseVolume, exec," wpctl " set-volume @DEFAULT_AUDIO_SINK@ 5%+ --limit 1.0\n"
"bindle=,XF86MonBrightnessDown,exec," light " -U 5\n"
"bindle=,XF86MonBrightnessUp, exec," light " -A 5\n"
"exec=" %hyprland-switch-keyboard-layout "\n"
"exec-once=" mako "\n"
"exec-once=" xdp-gtk " -r\n"
"exec-once=" xdp-hypr "\n"
"exec-once=sleep 5; exec " xdp " -r\n"
"exec-once=" wlsunset " -o eDP-1 " %dorphine-wlsunset-args "\n"
"exec-once=" swaybg " --image " wallpaper " --mode fill --output '*'\n")))
(define %config-wget
(plain-file
"wgetrc"
"hsts-file = ~/.cache/wget-hsts\n"))
(define %bashrc-direnv
(plain-file
"bashrc-direnv"
"
eval \"$(direnv hook bash)\""))
(define %bashrc-eat
(plain-file
"bashrc-eat"
"
[ -n \"$EAT_SHELL_INTEGRATION_DIR\" ] && \\
source \"$EAT_SHELL_INTEGRATION_DIR/bash\""))
(define %bashrc-liquidprompt
(mixed-text-file
"bashrc-liquidprompt"
"
[[ $- = *i* ]] && source " liquidprompt "/share/liquidprompt/liquidprompt"))
(define %bashrc-zoxide
(plain-file
"bashrc-zoxide"
"
eval \"$(zoxide init --cmd cd bash)\""))
(define %shell-profile-nvidia
(plain-file
"shell-profile-nvidia"
"
if [ -d /proc/driver/nvidia ]; then
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export __NV_PRIME_RENDER_OFFLOAD=1
fi"))
(define %shell-profile-wm
(plain-file
"shell-profile-wm"
"
if [ -z \"${WAYLAND_DISPLAY}\" ] && [ \"${XDG_VTNR}\" -eq 1 ]; then
exec env XDG_CURRENT_DESKTOP=Hyprland Hyprland
fi"))
;;
;; Mcron jobs
;;
(define %mcron-job-modprobed-db
#~(job next-hour-from
#$(file-append modprobed-db "/bin/modprobed-db storesilent")))
;;
;; Package bundles
;;
(define %home-packages
(append (list b4
dconf
direnv
firefox/dolly
git
`(,git "send-email")
git-crypt
gnupg
hyprland
imv
man-pages
mosh
mpv/dolly
netcat-openbsd
openssh-sans-x
pass-otp
password-store
qtwayland-5
rofi-wayland
rsync
steam/dolly
tessen
unzip
virt-manager
wl-clipboard
xdg-desktop-portal
xdg-desktop-portal-gtk
xdg-desktop-portal-hyprland
xdg-utils
zoxide
zstd)
(list tree-sitter-bash
tree-sitter-c
tree-sitter-cmake
tree-sitter-cpp
tree-sitter-c-sharp
tree-sitter-css
tree-sitter-dockerfile
tree-sitter-go
tree-sitter-gomod
tree-sitter-java
tree-sitter-javascript
tree-sitter-json
tree-sitter-python
tree-sitter-ruby
tree-sitter-rust
tree-sitter-typescript
tree-sitter-yaml)
(list adwaita-icon-theme
qogir-icon-theme)
(list font-adobe-source-sans-pro
font-adobe-source-serif-pro
font-cardo
font-chiron-hei-hk
font-chiron-sung-hk
font-google-noto
font-google-noto-emoji
font-google-noto-sans-cjk
font-google-noto-serif-cjk
font-lxgw-wenkai
font-lxgw-wenkai-tc
font-sarasa-gothic
font-victor-mono)))
;;
;; Home environment definition for Dorphine.
;;
(home-environment
(packages %home-packages)
(services
(list (service home-bash-service-type
(home-bash-configuration
(aliases
`(("ls" . ,(string-join '("ls"
"--classify"
"--color"
"--group-directories-first"
"--human-readable"
"--hyperlink")))))
(bashrc
(list %bashrc-direnv
%bashrc-eat
%bashrc-liquidprompt
%bashrc-zoxide))))
(service home-channels-service-type
(list %channel-guix
%channel-guixcn
%channel-nonguix
%channel-rosenthal))
(service home-dbus-service-type)
(service home-dotfiles-service-type
(home-dotfiles-configuration
(layout 'stow)
(directories '("./dotfiles"))))
(service home-emacs-service-type
%dorphine-home-emacs-configuration)
(service home-files-service-type
`((".guile" ,%default-dotguile)))
(service home-gpg-agent-service-type
(home-gpg-agent-configuration
(pinentry-program
(file-append pinentry-rofi/dolly "/bin/pinentry-rofi"))
(ssh-support? #t)))
(service home-mcron-service-type
(for-home
(mcron-configuration
(jobs (list %mcron-job-modprobed-db)))))
(service home-openssh-service-type
(home-openssh-configuration
(hosts %dorphine-ssh-hosts)))
(service home-pipewire-service-type
(home-pipewire-configuration
(wireplumber wireplumber-minimal)))
(service home-syncthing-service-type
(for-home
(syncthing-configuration
(user "hako"))))
(service home-xdg-configuration-files-service-type
`(("alacritty/alacritty.toml" ,%config-alacritty)
("gdb/gdbinit" ,%default-gdbinit)
("hypr/hyprland.conf" ,%config-hyprland)
("nano/nanorc" ,%default-nanorc)
("rclone/rclone.conf" ,(testament-file-object "rclone.conf"))
("wgetrc" ,%config-wget)))
(simple-service 'setup-env-vars
home-environment-variables-service-type
`(,@%testament-xdg-base-directory-env-vars
("BROWSER" . "firefox")
("EDITOR" . "emacsclient")
("HISTSIZE" . "10000")
("VISUAL" . "$EDITOR")))
(simple-service 'setup-shell-profile
home-shell-profile-service-type
(list %shell-profile-nvidia
%shell-profile-wm)))))