-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfiguration.scm
1209 lines (1084 loc) · 42.5 KB
/
configuration.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
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
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;; SPDX-License-Identifier: GPL-3.0-or-later
;; Copyright © 2021-2025 Nicolas Graves <[email protected]>
;; I embraced system crafting for long-term resilience and efficiency reasons.
;; This repository is a resource for cherry-picking code snippets and holds all
;; my configs, made clean and compact by RDE and GNU Guix.
;; To develop Guix/RDE rapidly, I use local repositories and tooling.
;; This file uses a dispatch to work with several commands: guix rde/home/system
;; See used channels at ./channels.scm
;; Tip: to sign commits when broken: `git --no-gpg-sign'
(use-modules (ice-9 ftw)
(ice-9 popen)
(ice-9 rdelim)
(srfi srfi-1)
(srfi srfi-2)
(srfi srfi-26)
(guix build utils)
(guix derivations)
(guix download)
(guix gexp)
(guix git-download)
(guix monads)
(guix packages)
(guix store)
(rde features)
((rde packages) #:select (strings->packages))
((gnu services) #:select (simple-service))
((guix packages) #:select (origin base32 package))
((guix records) #:select (recutils->alist))
((guix ui) #:select (with-error-handling))
((guix utils) #:select (readlink*))
((gnu services) #:select (simple-service etc-service-type service))
(guix build-system channel)
(guix build-system font)
(gnu packages fonts)
(nonguix licenses)
(rde home services emacs)
(nongnu packages linux)
)
(eval-when (eval load compile)
(begin
(define (name->feature-module name)
`(rde features ,(string->symbol name)))
(define %feature-modules
(map (compose name->feature-module (cut string-drop-right <> 4))
(scandir (find directory-exists?
(map (cut string-append <> "/rde/features")
%load-path))
(cut string-suffix? ".scm" <>))))
((@@ (gnu) %try-use-modules) %feature-modules #f (const #t))))
(define cwd (dirname (current-filename)))
(define (sanitize-home-string str homedir)
(if (string-prefix? "~" str)
(string-append homedir (string-drop str 1))
str))
(define (find-home str)
(sanitize-home-string str (getenv "HOME")))
(use-modules
;; Modules for make.
(srfi srfi-1) (srfi srfi-9 gnu) (srfi srfi-71) (srfi srfi-26) (git)
(ice-9 match) (ice-9 textual-ports) (ice-9 popen)
(guix gexp) (guix build utils) (guix channels) (guix records)
(gnu home) (gnu system)
(gnu system image) ((gnu image) #:hide (partition))
;; ((rde features) #:select (rde-config-home-environment
;; rde-config-operating-system))
((guix profiles) #:select (manifest-entries
manifest-entry-properties
%profile-directory
profile-manifest
generation-number
generation-file-name))
((guix store) #:select (with-store run-with-store
%store-monad mapm/accumulate-builds))
;; Modules for machine helpers.
(guix records)
(rde features system)
(srfi srfi-1) (ice-9 popen) (ice-9 rdelim) (ice-9 match)
(gnu system) (gnu system file-systems) (gnu system mapped-devices)
(gnu system uuid)
(gnu packages linux) (nongnu packages linux)
(nongnu system linux-initrd)
;; Modules for config.
(ice-9 popen) (ice-9 rdelim)
(srfi srfi-1) (ice-9 match)
(gnu system)
((guix build utils) #:select (find-files))
((gnu packages) #:select (specification->package))
((rde packages) #:select (strings->packages))
((gnu services) #:select (simple-service etc-service-type service))
((guix download) #:select (url-fetch url-fetch/zipbomb))
((guix packages) #:select (origin base32 package))
((guix ui) #:select (with-error-handling))
((guix utils) #:select (readlink*))
(guix build-system channel)
(guix build-system font) (gnu packages fonts) (nonguix licenses)
(guix gexp) (guix packages) (guix git-download) (guix git) (guix monads)
(guix scripts system) (guix scripts system reconfigure) (gnu bootloader)
;; Modules for live config
;; Other modules.
(rde features)
(gnu services)
(gnu system file-systems)
(rde home services emacs)
(contrib features emacs-xyz)
(contrib features age)
(nongnu packages linux)
(gnu packages emacs-xyz)
;; (gnu home services)
;; (gnu home services guix)
;; (gnu home services ssh)
(guix derivations))
(define config-file
(string-append (dirname (current-filename)) "/configuration.scm"))
(define btrbk-conf
(string-append (dirname (current-filename)) "/files/btrbk.conf"))
;;; Substitutes helpers
(define %base-services-feature
(delay
(feature-base-services
#:guix-substitute-urls
(cons* "https://substitutes.nonguix.org"
"https://guix.bordeaux.inria.fr"
(@ (guix store) %default-substitute-urls))
#:guix-authorized-keys
(cons*
(origin
(method url-fetch)
(uri "https://substitutes.nonguix.org/signing-key.pub")
(sha256
(base32 "0j66nq1bxvbxf5n8q2py14sjbkn57my0mjwq7k1qm9ddghca7177")))
(origin
(method url-fetch)
(uri "https://guix.bordeaux.inria.fr/signing-key.pub")
(sha256
(base32 "056cv0vlqyacyhbmwr5651fzg1icyxbw61nkap7sd4j2x8qj7ila")))
(@ (gnu services base) %default-authorized-guix-keys)))))
;;; Live systems.
(define my-installation-os
(delay
(begin
(use-modules (rde features)
(rde features base)
(rde features keyboard)
(rde features system)
(rde features linux)
(gnu services networking)
(gnu system install)
(nongnu packages linux)
(rde packages)
(gnu services))
(rde-config-operating-system
(rde-config
(initial-os installation-os)
(features
(list
(feature-keyboard
#:keyboard-layout
(keyboard-layout "fr" "," #:options '("caps:escape")))
(feature-hidpi)
(feature-kernel
#:kernel linux
#:firmware (list linux-firmware))
(feature-base-packages
#:system-packages
(strings->packages "git" "zip" "unzip" "curl"
"exfat-utils" "fuse-exfat" "ntfs-3g"))
(feature-custom-services
#:feature-name-prefix 'live
#:system-services
(list
;; (simple-service
;; 'channels-and-sources
;; etc-service-type
;; `(("channels.scm" ,(local-file "/home/graves/.config/guix/channels.scm"))
;; ("guix-sources" ,(local-file "/home/graves/spheres/info/guix" #:recursive? #t))
;; ("nonguix-sources" ,(local-file "/home/graves/spheres/info/nonguix" #:recursive? #t))
;; ("rde-sources" ,(local-file "/home/graves/spheres/info/rde" #:recursive? #t))))
(service wpa-supplicant-service-type)
(service network-manager-service-type)
(service (@@ (gnu system install) cow-store-service-type) 'mooh!)))
(feature-shepherd)
(force %base-services-feature))))))))
;;; Hardware/Host file systems
(define %host-features
(list
(feature-host-info
#:host-name "guix"
#:timezone "Europe/Paris"
#:locale "fr_FR.utf8")
(feature-hidpi)))
;; Privacy without GNUPG: currently using age with ssh and git commit signing. ;; TODO more details later.
;; Tip: sign outside git with ssh: `ssh-keygen -Y sign -n "file" -f /.ssh/id_ed25519_sk < "${file_to_sign}" > "${file_to_sign}.asc"'
(define %user-features
(list
(feature-age
#:age (hidden-package (@ (gnu packages golang-crypto) age))
#:age-ssh-key (find-home "~/.local/share/ssh/id_encrypt"))
(feature-security-token)
(feature-password-store
#:default-pass-prompt? #t
#:password-store (@ (gnu packages password-utils) pass-age)
#:password-store-directory (string-append cwd "/files/pass")
#:remote-password-store-url "[email protected]:~ngraves/pass")
(feature-user-info
#:user-name "graves"
#:full-name "Nicolas Graves"
#:email "[email protected]"
#:user-initial-password-hash
"$6$zds6yx8zRvS3Oo7L$yM0SRwidUNhq3bsaqpvbizCQKhpJWqr5eWtzOQJYzH5jshGygfGn/apoZL6zVXYc5Yr9/TguaCRu9Sk5lEyKE0"
#:emacs-advanced-user? #t)
(feature-keyboard
#:keyboard-layout
(keyboard-layout "fr" "," #:options '("caps:escape")))))
;;; Window management
(define background
(origin
(method url-fetch)
(uri "https://pour-un-reveil-ecologique.org/media/images/fond_pre.original.jpg")
(file-name "fond_pre.jpg")
(sha256 (base32 "03rn4fw9j31s7hl635q872hzxj4bj5m9hkjd4iqzl8z4lk0n9iiy"))))
(define %wm-features
(list
(feature-sway
#:xwayland? #f
#:extra-config
`((bindsym
--to-code
(;; ($mod+w exec chromium --remote-debugging-port=9222)
;; ($mod+Shift+w exec chromium --incognito --remote-debugging-port=9222)
($mod+Shift+m exec killall mpv)))
,@(append-map
(lambda (previous-key key number)
`((unbindsym ,(format #f "$mod+~a" previous-key))
(unbindsym ,(format #f "$mod+Shift+~a" previous-key))
(bindsym ,(format #f "$mod+~a" key)
workspace number ,number)
(bindsym ,(format #f "$mod+Shift+~a" key)
move container to workspace number ,number)))
(append (iota 9 1) '(0))
'(ampersand
eacute
quotedbl
apostrophe
parenleft
minus
egrave
underscore
ccedilla
agrave)
(iota 10 1))
(exec wlsunset -l 48.86 -L 2.35 -T 6500 -t 3000)
(workspace_auto_back_and_forth yes)
(focus_follows_mouse no)
(smart_borders on)
(title_align center)
(output * bg ,background fill)
(for_window "[app_id=\"^.*\"]" inhibit_idle fullscreen)
(for_window
"[title=\"^(?:Open|Save) (?:File|Folder|As).*\"]"
floating enable, resize set width 70 ppt height 70 ppt)
;; (bindswitch --reload --locked lid:on exec /run/setuid-programs/swaylock)
;; (bindsym $mod+Shift+o ,#~"[floating]" kill)
(input type:touchpad
;; TODO: Move it to feature-sway or feature-mouse?
( ;; (natural_scroll enabled)
(tap enabled)))))
(feature-sway-run-on-tty
#:sway-tty-number 1
;; Currently not working properly on locking
;; see https://github.com/NVIDIA/open-gpu-kernel-modules/issues/472
#:launch-arguments "--unsupported-gpu")
(feature-sway-screenshot
#:screenshot-key 'F10)
(feature-waybar
#:waybar-modules
(list
;; (waybar-sway-workspaces)
;; (waybar-sway-window)
(waybar-tray)
(waybar-idle-inhibitor)
(waybar-microphone)
(waybar-volume)
(waybar-temperature)
(waybar-sway-language)
(waybar-battery #:intense? #f)
(waybar-clock))
#:base16-css
(let* ((commit "d2f943b1abb9c9f295e4c6760b7bdfc2125171d2")
(name "base16-default-dark.css"))
(origin
(method url-fetch)
(uri
(string-append
"https://raw.githubusercontent.com/mnussbaum/base16-waybar/"
commit "/colors/" name))
(sha256
(base32 "1dncxqgf7zsk39bbvrlnh89lsgr2fnvq5l50xvmpnibk764bz0jb")))))
(feature-swayidle)
(feature-swaylock
#:swaylock (@ (gnu packages wm) swaylock-effects)
#:extra-config
`((clock)
,#~(string-append
"image="
#$(origin
(method url-fetch)
(uri "https://pour-un-reveil-ecologique.org/media/images/fond_lock_pre.original.jpg")
(file-name "fond_lock_pre.jpg")
(sha256
(base32 "1cyvaj0yvy6zvzy9yf1z6i629rwjcq3dni01phb599sp4n2cpa8g"))))))
(feature-swaynotificationcenter)))
;;; Mail
(define %mail-list
(let ((passdir (string-append cwd "/files/pass")))
(cons*
"[email protected]" ; ensuring primary_email
(delete "[email protected]"
(map (lambda file
(string-drop
(string-drop-right (car file) (string-length ".age"))
(+ 1 (string-length passdir))))
(find-files passdir "@[-a-z\\.]+\\.[a-z]{2,3}\\.age$"))))))
(define (id->type id)
(cond
((string=? id "ngmx") 'gmx-fr)
((string=? id "ngmail") 'gmail)
((string=? id "nngraves") 'ovh)
(else #f)))
(define (user->id user)
(string-append
(string-take user 1)
(car (string-split (car (cdr (string-split user #\@))) #\.))))
(define* (single-mail-acc user)
"Make a simple mail-account with ovh type by default."
(and-let* ((id_ (user->id user))
(type (id->type id_)))
(mail-account
(id (string->symbol id_))
(fqda user)
(type type)
(pass-cmd (string-append "passage show " user " | head -1")))))
(define* (mail-lst id fqda urls)
"Make a simple mailing-list."
(mailing-list
(id id)
(fqda fqda)
(config (l2md-repo
(name (symbol->string id))
(urls urls)))))
(define %mail-features
(delay
(list
(feature-mail-settings
#:mail-accounts
(filter-map single-mail-acc %mail-list)
#:mail-directory-fn (const (string-append (getenv "XDG_STATE_HOME") "/mail"))
#:mailing-lists (list (mail-lst 'guix-devel "[email protected]"
'("https://yhetil.org/guix-devel/0"))
(mail-lst 'guix-bugs "[email protected]"
'("https://yhetil.org/guix-bugs/0"))
(mail-lst 'guix-patches "[email protected]"
'("https://yhetil.org/guix-patches/1"))))
(feature-msmtp)
(feature-isync
#:mail-account-ids
(append-map
(lambda (x) (list (string->symbol (user->id x)))) %mail-list)
#:isync-verbose #t)
(feature-notmuch)
(feature-l2md)
(feature-emacs-piem
#:piem-inboxes `(("rde-devel"
:url "https://lists.sr.ht/~abcdw/rde-devel"
:address "~abcdw/[email protected]"
:coderepo (,(string-append (getcwd) "/channels/rde/")
"~/projects/src/emacs-arei/"
"~/projects/src/guile-ares-rs/"))
("guix-patches"
:url "https://yhetil.org/guix-patches/"
:address "[email protected]"
:coderepo ,(string-append (getcwd) "/channels/rde/")))))))
;;; SSH
(define private-key
(find-home "~/.local/share/ssh/id_encrypt"))
;; Maybe there a better way to send the pipe into a guix shell with all three
;; packages given with (specifications->manifest)
(define* (package-get-file store package
#:optional file
#:key (output "out") (system (%current-system)))
"Return the absolute file name of FILE within the OUTPUT directory of
PACKAGE for SYSTEM. When FILE is omitted, return the name of the OUTPUT
directory of PACKAGE for SYSTEM.
This procedure builds upon package-file and package-output, but _does_ build
PACKAGE when it's not available in the store. Note that this procedure calls
`package-derivation', which is costly."
(let* ((drv (package-derivation store package system))
(out (derivation->output-path drv output))
(result (and file (string-append out file))))
(unless (directory-exists? out)
(build-derivations store (list drv)))
(or (and (file-exists? result) result) out)))
(define (ssh-config id)
(let* ((age
(with-store store
(package-get-file
store (@ (gnu packages golang-crypto) age) "/bin/age")))
(passage
(with-store store
(package-get-file
store (@ (gnu packages password-utils) pass-age) "/bin/passage")))
(env
(with-store store
(package-get-file
store (@ (gnu packages base) coreutils-minimal) "/bin/env")))
(port
(open-input-pipe
(string-append
env " -S"
" PASSAGE_AGE=" age
" PASSAGE_DIR=" (string-append cwd "/files/pass")
" PASSAGE_IDENTITIES_FILE=" private-key
" PASSAGE_RECIPIENTS_FILE=" private-key ".pub "
passage " show ssh/ssh_" id " 2>/dev/null")))
(key (read-line port))
(alist (recutils->alist port)))
(close-pipe port)
(ssh-host
(host id)
(options
`((hostname . ,(assoc-ref alist "URI"))
(identity-file . ,(string-append "~/.local/share/ssh/" key))
(port . ,(and=> (assoc-ref alist "Port") string->number))
(user . ,(assoc-ref alist "Username")))))))
(define %ssh-feature
(delay
(feature-ssh
#:ssh-agent? #t
#:ssh-configuration
(home-ssh-configuration
(package (@ (gnu packages ssh) openssh-sans-x))
(user-known-hosts-file
'("/home/graves/.local/share/ssh/known_hosts"))
(default-host "*")
(default-options
'((address-family . "inet")))
(extra-config
`(,(ssh-config "inari")
,(ssh-config "pre_site"))))
#:ssh-add-keys '("/home/graves/.local/share/ssh/id_sign"))))
;;; Emacs
;; TODO Find a way to clarify current organization with much less text, more code.
;; PARA method (https://fortelabs.com/blog/para/) with directories spheres/resources/projects/archives.
;; with resources managed with: see ./hooks/git-biblio-prepare-commit-msg
(define %org-agenda-custom-commands
''(("ca" "Custom: Agenda TODO [#A] items"
((org-ql-block '(and (todo "TODO")
(priority "A"))
((org-ql-block-header "TODO : High-priority")))))
("ct" "Custom: Agenda TODO items"
((org-ql-block '(todo "TODO")
((org-ql-block-header "TODO : All items")))))))
(define %extra-init-el
`(;; Use RDE style.
(let ((rde-class (dir-locals-read-from-dir
,(string-append cwd "/channels/rde"))))
(dir-locals-set-directory-class ,cwd rde-class)
(dir-locals-set-class-variables
(intern ,cwd)
'((nil
. ((eval
. (progn
(unless (boundp 'geiser-guile-load-path)
(defvar geiser-guile-load-path '()))
(make-local-variable 'geiser-guile-load-path)
(mapc
(lambda (channel)
(add-to-list
'geiser-guile-load-path
(concat ,(string-append cwd "/channels/") channel)))
(list "guix" "nonguix" "odf-dsfr" "rde"))))))))
(dir-locals-set-directory-class ,cwd (intern ,cwd)))
(defun format-xml ()
"Format XML files using libxml2."
(interactive)
(shell-command-on-region
1 (point-max)
,(file-append (@(gnu packages xml) libxml2) "/bin/xmllint --format -")
(current-buffer) t))
;; clocking
(setq org-clock-persist 'history)
(org-clock-persistence-insinuate)
(setq
org-clock-persist-file
(concat (or (getenv "XDG_CACHE_HOME") "~/.cache")
"/emacs/org-clock-save.el"))
;; clocking in the task when setting a timer on a task
(add-hook 'org-timer-set-hook 'org-clock-in)
;; html email and elfeed
(setq shr-current-font "Iosevka")
;; help in learning keybindings
(global-set-key (kbd "s-?") (lambda () (interactive) (embark-bindings t)))
;; fast smartparens toggle
(global-set-key (kbd "s-)") 'smartparens-strict-mode)
;; don't save command-history, can be very big and not that useful
(with-eval-after-load 'savehist
(add-to-list 'savehist-ignored-variables 'command-history))
;; bibliography
(setq citar-library-file-extensions '("pdf.lz" "pdf" "docx.lz"))
(require 'f)
(setq biblio-bibtex-use-autokey t)
(setq bibtex-autokey-year-title-separator "_")
(setq bibtex-autokey-year-length 4)
(defun refresh-gen-biblio ()
"Regenerates the generated gen.bib file based on the list in dois.txt."
(interactive)
(if (file-readable-p "~/resources/gen.bib")
(with-temp-file "/tmp/retrieved_dois.txt"
(maphash
(lambda (k v)
(insert
(concat (cdr (car v)) "\n")))
(parsebib-parse "~/resources/gen.bib"
:fields '("doi"))))
(f-touch "/tmp/retrieved_dois.txt"))
(with-temp-buffer
(let ((biblio-synchronous t))
(mapcar (lambda (x) (biblio-doi-insert-bibtex x))
(cl-set-exclusive-or
(s-split "\n" (f-read "~/resources/dois.txt") t)
(s-split "\n" (f-read "/tmp/retrieved_dois.txt") t)
:test 'string-equal-ignore-case)))
(append-to-file nil nil "~/resources/gen.bib")))))
(define %additional-elisp-packages
(cons*
(@(rde packages emacs-xyz) emacs-git-email-latest)
(package
(inherit emacs-biblio)
(arguments
(list
#:phases
#~(modify-phases %standard-phases
(add-after 'unpack 'configure-const
(lambda _
(substitute* "biblio-doi.el"
(("text\\/bibliography;style=bibtex, application\\/x-bibtex")
"application/x-bibtex"))))))))
;; (let ((commit "24164db7c323488fabd72d5f725254721f309573")
;; (revision "0"))
;; (package
;; (inherit (@(nongnu packages emacs) emacs-org-roam-ui))
;; (name "emacs-org-roam-ui")
;; (version (git-version "0" revision commit))
;; (source
;; (origin
;; (method git-fetch)
;; (uri (git-reference
;; (url "https://github.com/org-roam/org-roam-ui")
;; (commit commit)))
;; (file-name (string-append name "-" version "-checkout"))
;; (sha256
;; (base32
;; "1jfplgmx6gxgyzlc358q94l252970kvxnig12zrim2fa27lzmpyj"))))))
;; (hidden-package (@ (nrepl-python-channel) nrepl-python))
(strings->packages
"emacs-piem"
"emacs-hl-todo"
"emacs-consult-dir"
"emacs-consult-org-roam"
"emacs-restart-emacs"
"emacs-csv-mode"
"emacs-org-glossary"
;; "emacs-macrostep"
;; "emacs-ibrowse"
"emacs-link-hint"
;; "emacs-forge"
"emacs-origami-el"
"emacs-emojify"
"emacs-wgrep"
"emacs-gptel"
;; "emacs-flycheck-package"
;; "python-lsp-server"
"emacs-shackle"
"emacs-combobulate"
"emacs-org-pomodoro")))
(define %emacs-features
(list
(feature-emacs
#:default-application-launcher? #t)
(feature
(name 'emacs-custom)
(home-services-getter
(const
(list
(simple-service
'emacs-extensions
home-emacs-service-type
(home-emacs-extension
(init-el %extra-init-el)
(elisp-packages %additional-elisp-packages)))))))
(feature-emacs-message)
(feature-emacs-appearance)
(feature-emacs-modus-themes
#:deuteranopia? #f)
(feature-emacs-completion)
(feature-emacs-corfu)
(feature-emacs-vertico)
(feature-emacs-pdf-tools)
(feature-emacs-devdocs)
(feature-emacs-dape)
(feature-emacs-nov-el)
(feature-emacs-comint)
(feature-emacs-webpaste)
(feature-emacs-help)
(feature-emacs-all-the-icons)
(feature-emacs-debbugs)
(feature-emacs-flymake)
(feature-emacs-xref)
(feature-emacs-info)
(feature-emacs-spelling
#:spelling-program (@ (gnu packages hunspell) hunspell)
#:spelling-dictionaries (strings->packages
"hunspell-dict-en"
"hunspell-dict-fr"))
(feature-emacs-tramp)
;; I lost the work on emacs-dirvish...
;;(feature-emacs-dirvish
;; #:attributes '(file-size))
(feature-emacs-eshell)
(feature-emacs-monocle
#:olivetti-body-width 120)
;; (feature-emacs-telega)
(feature-emacs-git)
(feature-emacs-org
#:org-directory (find-home "~")
#:org-todo-keywords
'((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!)")
(sequence "|" "HOLD(h)")) ; waiting for someone to be ationable again
#:org-tag-alist
'((:startgroup)
;; Put mutually exclusive tags here
(:endgroup)
("@home" . ?H)
("@work" . ?W)
("batch" . ?b) ; batchable task
("manage" . ?m) ; I'm responsible for the rythm of others
("organize" . ?o) ; better organization
("followup" . ?f))) ; someone is waiting on me to follow up
(feature-emacs-org-agenda
#:org-agenda-appt? #t
#:org-agenda-custom-commands %org-agenda-custom-commands
#:org-agenda-files "/home/graves/.cache/emacs/org-agenda-files")
(feature-emacs-smartparens #:show-smartparens? #t)
(feature-emacs-eglot)
(feature-emacs-geiser)
(feature-emacs-graphviz)
(feature-emacs-guix
#:guix-directory "/home/graves/spheres/info/guix")
(feature-emacs-tempel #:default-templates? #t)
(feature-emacs-meow)
(feature-emacs-undo-fu-session)
(feature-emacs-elfeed #:elfeed-org-files '("~/resources/feeds.org"))
(feature-emacs-org-ql)
(feature-emacs-org-agenda-files-track)
(feature-emacs-org-dailies
#:org-dailies-directory "~/spheres/life/journal/"
#:org-roam-dailies? #f)
(feature-emacs-org-roam
#:org-roam-directory "~/resources/roam/"
#:org-roam-capture-templates ;resource template is provided by citar
'(("m" "main" plain "%?"
:if-new (file+head "main/${slug}.org" "#+title: ${title}\n")
:immediate-finish t
:unnarrowed t)))
(feature-emacs-citation
#:citar-library-paths (list "~/resources/files/library")
#:citar-notes-paths (list "~/resources/roam/references")
#:global-bibliography (list "~/resources/biblio.bib" "~/resources/gen.bib"))
(feature-emacs-treebundel
#:treebundel-workspace-root "~/spheres/info/")
(feature-go)
(feature-guile)
(feature-python)
(feature-emacs-elisp)
(feature-emacs-power-menu)
(feature-emacs-shell)
(feature-emacs-project)))
;;; Main features
(define %main-features
(append
(list
(feature-custom-services
#:feature-name-prefix 'cups
#:system-services
(list (service (@ (gnu services cups) cups-service-type))))
;; (feature-postgresql
;; #:postgresql-roles
;; (list (postgresql-role (name "manifesto") (create-database? #t))))
;; (feature-docker)
(feature-desktop-services)
(feature-backlight #:step 5)
(feature-pipewire)
(feature-networking)
;; (feature-bluetooth)
(feature-fonts
#:default-font-size 14
#:extra-font-packages
(list font-gnu-unifont font-liberation
(@ (odf-dsfr packages fonts) font-marianne)))
(feature-foot
#:default-terminal? #f
#:backup-terminal? #t)
(feature-vterm)
(feature-zsh #:enable-zsh-autosuggestions? #t)
(feature-bash)
;; (feature-transmission)
(feature-compile)
(feature-direnv)
(feature-git
#:sign-commits? #t
#:git-sign-key
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINd9BmbuU3HS6pbCzCe1IZGxaHHDJERXpQRZZiRkfL3a"
#:git-send-email? #t)
;; (feature-ledger)
(feature-markdown)
(feature-tex)
(feature-mpv)
;; (feature-yt-dlp)
(feature-imv)
(feature-libreoffice)
(feature-qemu)
(feature-tmux)
;; (feature-ungoogled-chromium #:default-browser? #t)
(feature-librewolf
#:browser (hidden-package (@ (nongnu packages mozilla) firefox)))
;; (feature-nyxt)
;; (feature-emacs-nyxt)
;; ((@(rde features lisp) feature-lisp))
;; ((@(rde features nyxt-xyz) feature-nyxt-blocker))
(feature-xdg
#:xdg-user-directories-configuration
(home-xdg-user-directories-configuration
(download "~/.local/share/downloads")
(videos "~/archives/videos")
(music "~/archives/music")
(pictures "~/archives/img")
(documents "~/resources")
(desktop "~")
(publicshare "~")
(templates "~")))
(feature-base-packages
#:home-packages
(cons*
(hidden-package (@ (gnu packages tree-sitter) tree-sitter-python))
(hidden-package (@ (gnu packages version-control) git-lfs))
(map
hidden-package
(strings->packages
"hicolor-icon-theme" "adwaita-icon-theme" ; themes
"alsa-utils" ; sound
"rsync" "zip" ; "thunar" ; documents
"wev" "wlsunset" "cage" ; wayland
"recutils" "curl" "jq" "htop" "git-filter-repo" ; utils
"btrbk" ; snapshot btrfs subvolumes
"atool" "unzip" ; provides generic extract tool aunpack
"ccls"
;; "nerd-dictation-sox-wtype"
))
)))
%wm-features
%emacs-features))
;;; Machine helpers
(define root-impermanence-btrfs-layout
'((store . "/gnu/store")
(guix . "/var/guix")
(log . "/var/log")
(lib . "/var/lib")
(boot . "/boot")
(NetworkManager . "/etc/NetworkManager")))
(define home-impermanence-para-btrfs-layout
(append-map
(lambda (subvol)
(list
(cons (string->symbol
(if (string-prefix? "." subvol)
(string-drop subvol 1)
subvol))
(string-append "/home/graves/" subvol))))
'("projects" "spheres" "resources" "archives" ".local" ".cache")))
(define %nvidia-services
(delay
(list ;; Currently not working properly on locking
;; see https://github.com/NVIDIA/open-gpu-kernel-modules/issues/472
(service (@ (nongnu services nvidia) nvidia-service-type)
((@ (nongnu services nvidia) nvidia-configuration)
(driver (hidden-package
(package
(inherit (@ (gnu packages gl) mesa))
(replacement (@ (nongnu packages nvidia) nvdb)))))
(firmware (@ (nongnu packages nvidia) nvidia-firmware-beta))
(module (@ (nongnu packages nvidia) nvidia-module-beta))))
(simple-service 'nvidia-mesa-utils-package
profile-service-type
(list (@ (gnu packages gl) mesa-utils))))))
(define-record-type* <machine> machine make-machine
machine?
this-machine
(name machine-name) ; string
(efi machine-efi) ; file-system
(encrypted-uuid-mapped machine-encrypted-uuid-mapped ; maybe-uuid
(default #f))
(btrfs-layout machine-btrfs-layout ; alist
(default root-impermanence-btrfs-layout))
(architecture machine-architecture ; string
(default "x86_64-linux"))
(firmware machine-firmware ; list of packages
(delayed)
(default '()))
(kernel-build-options machine-kernel-build-options ; list of options
(default '())))
(define (machine-root-impermanence? machine)
(not (assoc 'root (machine-btrfs-layout machine))))
(define (machine-home-impermanence? machine)
(not (assoc 'home (machine-btrfs-layout machine))))
(define %machines
(list
(machine (name "Precision 3571")
(efi "/dev/nvme0n1p1")
(encrypted-uuid-mapped "92f9af3d-d860-4497-91ea-9e46a1dacf7a")
(btrfs-layout (append '(;;(data . "/data")
(btrbk_snapshots . "/btrbk_snapshots")
(mozilla . "/home/graves/.mozilla")
(zoom . "/home/graves/.zoom"))
root-impermanence-btrfs-layout
home-impermanence-para-btrfs-layout))
(firmware (list linux-firmware)))
(machine (name "20AMS6GD00")
(efi "/dev/sda1")
(encrypted-uuid-mapped "a9319ee9-f216-4cad-bfa5-99a24a576562"))
(machine (name "2325K55")
(efi "/dev/sda1")
(encrypted-uuid-mapped "824f71bd-8709-4b8e-8fd6-deee7ad1e4f0")
(btrfs-layout root-impermanence-btrfs-layout)
(firmware (list iwlwifi-firmware)))
;; Might use r8169 module but it works fine without, use linux-libre then.
(machine (name "OptiPlex 3020M")
(efi "/dev/sda1")
(encrypted-uuid-mapped "be1f04af-dafe-4e1b-8e8b-a602951eeb35")
(btrfs-layout root-impermanence-btrfs-layout))))
(define %current-machine
(let ((name (call-with-input-file
"/sys/devices/virtual/dmi/id/product_name"
read-line)))
(find (lambda (in) (equal? name (machine-name in)))
%machines)))
(define %mapped-device
(let ((uuid (bytevector->uuid
(string->uuid (machine-encrypted-uuid-mapped %current-machine)))))
(and (uuid? uuid)
(mapped-device
(source uuid)
(targets (list "enc"))
(type luks-device-mapping)))))
(define root-fs
(file-system
(mount-point "/")
(type (if (machine-root-impermanence? %current-machine)
"tmpfs"
"btrfs"))
(device (if (machine-root-impermanence? %current-machine)
"none"
"/dev/mapper/enc"))
(needed-for-boot? #t)
(check? #f)))
(define home-fs
(if (machine-home-impermanence? %current-machine)
(file-system
(mount-point "/home/graves")
(type "tmpfs")
(device "none")
;; User should have dir ownership.
(options "uid=1000,gid=998")
(dependencies (or (and=> %mapped-device list) '())))
(file-system
(mount-point "/home")
(type "btrfs")
(device "/dev/mapper/enc")
(options "autodefrag,compress=zstd,subvol=home")
(dependencies (or (and=> %mapped-device list) '())))))
(define get-btrfs-file-system
(match-lambda
((subvol . mount-point)
(file-system
(type "btrfs")
(device "/dev/mapper/enc")
(mount-point mount-point)
(options
(format #f "~asubvol=~a"
(if (string=? "/swap" mount-point)
"nodatacow,nodatasum,"
"autodefrag,compress=zstd,")
subvol))