source: dotfiles/guix/rde/src/configs.scm@ 420782f

Last change on this file since 420782f was 420782f, checked in by Mikhail Kirillov <mikhail.kirillov@…>, on Apr 19, 2023 at 9:25:51 PM

Add rde

  • Property mode set to 100644
File size: 16.9 KB
Line 
1(define-module (abcdw configs)
2 #:use-module (abcdw feature-lists)
3 #:use-module (abcdw hosts ixy)
4 #:use-module (abcdw hosts live)
5
6 #:use-module (rde features)
7 #:use-module (rde features base)
8 #:use-module (rde features gnupg)
9 #:use-module (rde features security-token)
10 #:use-module (rde features keyboard)
11 #:use-module (rde features system)
12 #:use-module (rde features xdg)
13 #:use-module (rde features password-utils)
14 #:use-module (rde features emacs-xyz)
15 #:use-module (rde features mail)
16 #:use-module (rde features irc)
17 #:use-module (rde features networking)
18 #:use-module (rde features clojure)
19 #:use-module (contrib features javascript)
20
21 #:use-module (gnu services)
22 #:use-module (gnu home services)
23 #:use-module (gnu home services shepherd)
24 #:use-module (gnu home services xdg)
25 #:use-module (rde home services i2p)
26 #:use-module (rde home services emacs)
27 #:use-module (rde home services wm)
28
29 #:use-module (gnu home-services ssh)
30
31 #:use-module (gnu packages)
32 #:use-module (rde packages)
33 #:use-module (rde packages aspell) ; needed for strings->packages
34
35 #:use-module (guix gexp)
36 #:use-module (guix inferior)
37 #:use-module (guix channels)
38 #:use-module (guix packages)
39 #:use-module (guix download)
40 #:use-module (ice-9 match))
41
42
43
44;;; Helpers
45
46(define* (mail-acc id user #:optional (type 'gmail))
47 "Make a simple mail-account with gmail type by default."
48 (mail-account
49 (id id)
50 (fqda user)
51 (type type)))
52
53(define* (mail-lst id fqda urls)
54 "Make a simple mailing-list."
55 (mailing-list
56 (id id)
57 (fqda fqda)
58 (config (l2md-repo
59 (name (symbol->string id))
60 (urls urls)))))
61
62
63
64;;; Service extensions
65
66(define emacs-extra-packages-service
67 (simple-service
68 'emacs-extra-packages
69 home-emacs-service-type
70 (home-emacs-extension
71 (init-el
72 `((with-eval-after-load 'org
73 (setq org-use-speed-commands t)
74 (define-key org-mode-map (kbd "M-o")
75 (lambda ()
76 (interactive)
77 (org-end-of-meta-data t))))
78 (with-eval-after-load 'simple
79 (setq-default display-fill-column-indicator-column 80)
80 (add-hook 'prog-mode-hook 'display-fill-column-indicator-mode))
81 (setq copyright-names-regexp
82 (format "%s <%s>" user-full-name user-mail-address))
83 (add-hook 'after-save-hook (lambda () (copyright-update nil nil)))))
84 (elisp-packages
85 (append
86 (strings->packages
87 ;; "emacs-dirvish"
88 "emacs-rainbow-mode"
89 "emacs-hl-todo"
90 "emacs-yasnippet"
91 ;; "emacs-company"
92 "emacs-consult-dir"
93 ;; "emacs-all-the-icons-completion" "emacs-all-the-icons-dired"
94 "emacs-kind-icon"
95 "emacs-nginx-mode" "emacs-yaml-mode"
96 ;; "emacs-lispy"
97 "emacs-ytdl"
98 "emacs-multitran"
99 "emacs-minimap"
100 "emacs-ement"
101 "emacs-restart-emacs"
102 "emacs-org-present"))))))
103
104(define home-extra-packages-service
105 (simple-service
106 'home-profile-extra-packages
107 home-profile-service-type
108 (append
109 (strings->packages
110 "figlet" ;; TODO: Move to emacs-artist-mode
111 "calibre"
112 "icecat" "nyxt"
113 "ungoogled-chromium-wayland" "ublock-origin-chromium"
114
115 "utox" "qtox" "jami"
116
117 "alsa-utils" "yt-dlp" "cozy"
118 "pavucontrol" "wev"
119 "imagemagick"
120 "obs" "obs-wlrobs"
121 "recutils" "binutils" "make"
122 "fheroes2"
123
124 "hicolor-icon-theme" "adwaita-icon-theme" "gnome-themes-extra"
125 "papirus-icon-theme" "arc-theme"
126 "thunar" "fd"
127 ;; "glib:bin"
128
129 "libreoffice"
130 "ffmpeg"
131 "ripgrep" "curl"))))
132
133(define (wallpaper url hash)
134 (origin
135 (method url-fetch)
136 (uri url)
137 (file-name "wallpaper.png")
138 (sha256 (base32 hash))))
139
140(define wallpaper-ai-art
141 (wallpaper "https://w.wallhaven.cc/full/j3/wallhaven-j3m8y5.png"
142 "0qqx6cfx0krlp0pxrrw0kvwg6x40qq9jic90ln8k4yvwk8fl1nyw"))
143
144(define wallpaper-dark-rider
145 (wallpaper "https://w.wallhaven.cc/full/lm/wallhaven-lmlzwl.jpg"
146 "01j5z3al8zvzqpig8ygvf7pxihsj2grsazg9yjiqyjgsmp00hpaf"))
147
148(define sway-extra-config-service
149 (simple-service
150 'sway-extra-config
151 home-sway-service-type
152 `((output DP-2 scale 2)
153 ;; (output * bg ,wallpaper-ai-art center)
154 ;; (output eDP-1 disable)
155 ,@(map (lambda (x) `(workspace ,x output DP-2)) (iota 8 1))
156
157 ;; (workspace 9 output DP-2)
158 ;; (workspace 10 output DP-2)
159
160 ;; (bindswitch --reload --locked lid:on exec /run/setuid-programs/swaylock)
161
162 (bindsym
163 --locked $mod+Shift+t exec
164 ,(file-append (@ (gnu packages music) playerctl) "/bin/playerctl")
165 play-pause)
166
167 (bindsym
168 --locked $mod+Shift+n exec
169 ,(file-append (@ (gnu packages music) playerctl) "/bin/playerctl")
170 next)
171
172 (bindsym $mod+Shift+o move workspace to output left)
173 (bindsym $mod+Ctrl+o focus output left)
174 (input type:touchpad
175 ;; TODO: Move it to feature-sway or feature-mouse?
176 (;; (natural_scroll enabled)
177 (tap enabled)))
178
179 ;; (xwayland disable)
180 (bindsym $mod+Shift+Return exec emacs))))
181
182(define i2pd-add-ilita-irc-service
183 (simple-service
184 'i2pd-add-ilita-irc
185 home-i2pd-service-type
186 (home-i2pd-extension
187 (tunnels-conf
188 `((IRC-ILITA ((type . client)
189 (address . 127.0.0.1)
190 (port . 6669)
191 (destination . irc.ilita.i2p)
192 (destinationport . 6667)
193 (keys . ilita-keys.dat))))))))
194
195(define ssh-extra-config-service
196 (simple-service
197 'ssh-extra-config
198 home-ssh-service-type
199 (home-ssh-extension
200 (extra-config
201 (append
202 ;; TODO: Move it feature-qemu?
203 (map (lambda (id)
204 (ssh-host
205 (host (format #f "qemu~a" id))
206 (options
207 `((host-name . "localhost")
208 (port . ,(+ 10020 id))))))
209 (iota 4))
210 (list
211 (ssh-host
212 (host "pinky-ygg")
213 (options
214 '((host-name . "200:554d:3eb1:5bc5:6d7b:42f4:8792:efb8")
215 (port . 50621)
216 (control-master . "auto")
217 (control-path . "~/.ssh/master-%r@%h:%p")
218 (compression . #t))))
219 (ssh-host
220 (host "pinky")
221 (options
222 '((host-name . "23.137.249.202")
223 (port . 50621)
224 (compression . #t)))))))
225 (toplevel-options
226 '((host-key-algorithms . "+ssh-rsa")
227 (pubkey-accepted-key-types . "+ssh-rsa"))))))
228
229
230
231;;; User-specific features with personal preferences
232
233;; Initial user's password hash will be available in store, so use this
234;; feature with care (display (crypt "hi" "$6$abc"))
235
236(define %abcdw-features
237 (list
238 (feature-user-info
239 #:user-name "bob"
240 #:full-name "Andrew Tropin"
241 #:email "andrew@trop.in"
242 #:user-initial-password-hash
243 "$6$abc$3SAZZQGdvQgAscM2gupP1tC.SqnsaLSPoAnEOb2k6jXMhzQqS1kCSplAJ/vUy2rrnpHtt6frW2Ap5l/tIvDsz."
244 ;; (crypt "bob" "$6$abc")
245
246 ;; WARNING: This option can reduce the explorability by hiding
247 ;; some helpful messages and parts of the interface for the sake
248 ;; of minimalistic, less distractive and clean look. Generally
249 ;; it's not recommended to use it.
250 #:emacs-advanced-user? #t)
251 (feature-gnupg
252 #:gpg-primary-key "74830A276C328EC2")
253 (feature-security-token)
254 (feature-password-store
255 #:remote-password-store-url "ssh://abcdw@olorin.lan/~/state/password-store")
256
257 (feature-mail-settings
258 #:mail-accounts (list (mail-acc 'work "andrew@trop.in" 'gandi)
259 (mail-acc 'personal "bs@trop.in" 'gandi))
260 #:mailing-lists (list (mail-lst 'guix-devel "guix-devel@gnu.org"
261 '("https://yhetil.org/guix-devel/0"))
262 (mail-lst 'guix-bugs "guix-bugs@gnu.org"
263 '("https://yhetil.org/guix-bugs/0"))
264 (mail-lst 'guix-patches "guix-patches@gnu.org"
265 '("https://yhetil.org/guix-patches/1"))))
266
267 (feature-irc-settings
268 #:irc-accounts (list
269 (irc-account
270 (id 'srht)
271 (network "chat.sr.ht")
272 (bouncer? #t)
273 (nick "abcdw"))
274 (irc-account
275 (id 'libera)
276 (network "irc.libera.chat")
277 (nick "abcdw"))
278 (irc-account
279 (id 'oftc)
280 (network "irc.oftc.net")
281 (nick "abcdw"))))
282
283 (feature-custom-services
284 #:feature-name-prefix 'abcdw
285 #:home-services
286 (list
287 emacs-extra-packages-service
288 home-extra-packages-service
289 sway-extra-config-service
290 ssh-extra-config-service
291 i2pd-add-ilita-irc-service))
292
293 (feature-ssh-proxy #:host "pinky-ygg" #:auto-start? #f)
294 (feature-ssh-proxy #:host "pinky-ygg" #:name "hundredrps"
295 #:proxy-string "50080:localhost:8080"
296 #:reverse? #t
297 #:auto-start? #f)
298
299 (feature-xdg
300 #:xdg-user-directories-configuration
301 (home-xdg-user-directories-configuration
302 (music "$HOME/music")
303 (videos "$HOME/vids")
304 (pictures "$HOME/pics")
305 (documents "$HOME/docs")
306 (download "$HOME/dl")
307 (desktop "$HOME")
308 (publicshare "$HOME")
309 (templates "$HOME")))
310
311 (feature-yggdrasil)
312 (feature-i2pd
313 #:outproxy 'http://acetone.i2p:3128
314 ;; 'purokishi.i2p
315 #:less-anonymous? #t)
316
317 (feature-emacs-keycast #:turn-on? #t)
318
319 (feature-emacs-tempel
320 #:default-templates? #t
321 #:templates
322 `(fundamental-mode
323 ,#~""
324 (t (format-time-string "%Y-%m-%d"))
325 ;; TODO: Move to feature-guix
326 ;; ,((@ (rde gexp) slurp-file-like)
327 ;; (file-append ((@ (guix packages) package-source)
328 ;; (@ (gnu packages package-management) guix))
329 ;; "/etc/snippets/tempel/text-mode"))
330 ))
331 (feature-emacs-time)
332 (feature-emacs-spelling
333 #:spelling-program (@ (gnu packages hunspell) hunspell)
334 #:spelling-dictionaries
335 (list
336 (@ (gnu packages hunspell) hunspell-dict-en)
337 (@ (rde packages aspell) hunspell-dict-ru)))
338 (feature-emacs-git
339 #:project-directory "~/work")
340 (feature-emacs-org
341 #:org-directory "~/work/abcdw/private"
342 #:org-indent? #f
343 #:org-capture-templates
344 ;; https://libreddit.tiekoetter.com/r/orgmode/comments/gc76l3/org_capture_inside_notmuch/
345 `(("r" "Reply" entry (file+headline "" "Tasks")
346 "* TODO Reply %:subject %?\nSCHEDULED: %t\n%U\n%a\n"
347 :immediate-finish t)
348 ("t" "Todo" entry (file+headline "" "Tasks") ;; org-default-notes-file
349 "* TODO %?\nSCHEDULED: %t\n%a\n" :clock-in t :clock-resume t)))
350 (feature-emacs-org-roam
351 ;; TODO: Rewrite to states
352 #:org-roam-directory "~/work/abcdw/notes/notes")
353 (feature-emacs-org-agenda
354 #:org-agenda-files '("~/work/abcdw/private/todo.org"
355 "~/work/abcdw/rde/TODO"))
356 (feature-emacs-elfeed
357 #:elfeed-org-files '("~/work/abcdw/private/rss.org"))
358
359
360 (feature-javascript)
361
362 ;; TODO: move feature to general, move extra configuration to service.
363 (feature-notmuch
364 ;; TODO: Add integration with mail-lists
365 ;; `notmuch-show-stash-mlarchive-link-alist'
366 #:extra-tag-updates-post
367 '("notmuch tag +guix-home -- 'thread:\"\
368{((subject:guix and subject:home) or (subject:service and subject:home) or \
369subject:/home:/) and tag:new}\"'")
370 #:notmuch-saved-searches
371 (cons*
372 ;; TODO: Add tag:unread to all inboxes. Revisit archive workflow.
373 '(:name "Work Inbox" :query "tag:work and tag:inbox and tag:unread" :key "W")
374 '(:name "Personal Inbox" :query "tag:personal and tag:inbox" :key "P")
375 '(:name "Guix Home Inbox" :key "H" :query "tag:guix-home and tag:unread")
376 '(:name "RDE Inbox" :key "R"
377 :query "(to:/rde/ or cc:/rde/) and tag:unread")
378 '(:name "New TODO" :query "tag:todo or (tag:inbox and not tag:unread)" :key "T")
379 ;; '(:name "Watching" :query "thread:{tag:watch} and tag:unread" :key "tw")
380 %rde-notmuch-saved-searches))
381
382 (feature-keyboard
383 ;; To get all available options, layouts and variants run:
384 ;; cat `guix build xkeyboard-config`/share/X11/xkb/rules/evdev.lst
385 #:keyboard-layout
386 (keyboard-layout
387 "us,ru" "dvorak,"
388 #:options '("grp:shifts_toggle" "ctrl:nocaps")))))
389
390(define %guest-features
391 (list
392 (feature-user-info
393 #:user-name "guest"
394 #:full-name "rde user"
395 #:email "guest@rde"
396 ;; (crypt "guest" "$6$abc")
397 #:user-initial-password-hash
398 "$6$abc$9a9KlQ2jHee45D./UOzUZWLHjI/atvz2Dp6.Zz6hjRcP2KJv\
399G9.lc/f.U9QxNW1.2MZdV1KzW6uMJ0t23KKoN/")
400
401 (feature-keyboard
402 ;; To get all available options, layouts and variants run:
403 ;; cat `guix build xkeyboard-config`/share/X11/xkb/rules/evdev.lst
404 #:keyboard-layout
405 (keyboard-layout
406 "us,us"
407 ",dvorak"
408 #:options '("grp:shifts_toggle" "ctrl:nocaps")))
409
410 (feature-irc-settings
411 #:irc-accounts (list
412 (irc-account
413 (id 'libera)
414 (network "irc.libera.chat")
415 (nick "rde-user"))
416 (irc-account
417 (id 'oftc)
418 (network "irc.oftc.net")
419 (nick "rde-user"))))))
420
421
422
423;;; Some TODOs
424
425;; TODO: Add an app for saving and reading articles and web pages
426;; https://github.com/wallabag/wallabag
427;; https://github.com/chenyanming/wallabag.el
428
429;; TODO: feature-wallpapers https://wallhaven.cc/
430;; TODO: feature-icecat
431;; TODO: Revisit <https://en.wikipedia.org/wiki/Git-annex>
432;; TODO: <https://www.labri.fr/perso/nrougier/GTD/index.html#table-of-contents>
433
434
435
436;;; ixy
437
438(define-public ixy-config
439 (rde-config
440 (features
441 (append
442 %all-features
443 %ixy-features
444 %abcdw-features))))
445
446(define-public ixy-os
447 (rde-config-operating-system ixy-config))
448
449(define-public ixy-he
450 (rde-config-home-environment ixy-config))
451
452
453
454;;; live
455
456(use-modules (srfi srfi-1)
457 (rde features version-control))
458
459(define sway-wlr-settings-service
460 (simple-service
461 'sway-wlr-settings
462 home-environment-variables-service-type
463 ;; Make sway work on virtual gpu in qemu
464 `(("WLR_RENDERER_ALLOW_SOFTWARE" . "1")
465 ("WLR_NO_HARDWARE_CURSORS" . "1"))))
466
467(define sway-live-extra-config-service
468 (simple-service
469 'sway-output-settings
470 home-sway-service-type
471 `((output Virtual-1 mode 1920x1080 scale 2)
472 (exec emacs --eval "'(info \"(rde)Getting Started\")'"))))
473
474(define home-profile-live-extra-packages-service
475 (simple-service
476 'home-profile-live-extra-packages
477 home-profile-service-type
478 (append
479 (strings->packages
480 "icecat"
481 "imv" "wev"
482 "make"
483 "adwaita-icon-theme" "gnome-themes-extra"
484 "hicolor-icon-theme" ;; needed for nm icons
485
486 "ripgrep" "curl"))))
487
488(define example-configs-service
489 (simple-service
490 'live-example-configs
491 home-shepherd-service-type
492 (list
493 (shepherd-service
494 (documentation "Create ~/rde-configs.")
495 (requirement '())
496 (provision '(rde-configs))
497 (start
498 (with-imported-modules '((guix build utils))
499 #~(lambda ()
500 (let ((rde-configs #$(local-file
501 "../.." "rde-configs"
502 #:recursive? #t
503 #:select?
504 (lambda (file _)
505 (not (string=? (basename file) "target")))))
506 (output (string-append (getenv "HOME") "/rde-configs")))
507 (when (not (file-exists? output))
508 (mkdir-p output)
509 (copy-recursively
510 rde-configs
511 output
512 #:copy-file (lambda (f t)
513 (copy-file f t)
514 (make-file-writable t)))
515 ;; MAYBE: take this value from rde-config
516 (system* #$(file-append (@ (gnu packages shellutils) direnv)
517 "/bin/direnv") "allow" output))))))
518 (one-shot? #t)))))
519
520(define live-custom-services
521 (feature-custom-services
522 #:feature-name-prefix 'live
523 #:home-services
524 (list
525 example-configs-service
526 sway-live-extra-config-service
527 sway-wlr-settings-service
528 home-profile-live-extra-packages-service)))
529
530;; TODO: Pull channels from lock file in advance and link them to example-config
531;; TODO: Add auto-login
532
533(define-public live-config
534 (rde-config
535 (integrate-he-in-os? #t)
536 (features
537 (append
538 %guest-features
539 (list live-custom-services)
540
541 (remove
542 (lambda (f) (member (feature-name f) '(git markdown)))
543 %general-features)
544 (list
545 (feature-git #:sign-commits? #f)
546 (feature-hidpi))
547
548 %live-features))))
549
550(define-public live-os
551 (rde-config-operating-system live-config))
552
553
554
555;;; Dispatcher, which helps to return various values based on environment
556;;; variable value.
557
558(define (dispatcher)
559 (let ((rde-target (getenv "RDE_TARGET")))
560 (match rde-target
561 ("ixy-home" ixy-he)
562 ("ixy-system" ixy-os)
563 ("live-system" live-os)
564 (_ ixy-he))))
565
566(dispatcher)
Note: See TracBrowser for help on using the repository browser.