-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
13922 lines (12561 loc) · 445 KB
/
index.html
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
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2024-08-31 Sa 18:00 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>SwarselSystems: NixOS + Emacs Configuration</title>
<meta name="author" content="Leon Schwarzäugl" />
<meta name="generator" content="Org Mode" />
<style type="text/css">
#content { max-width: 60em; margin: auto; }
.title { text-align: center;
margin-bottom: .2em; }
.subtitle { text-align: center;
font-size: medium;
font-weight: bold;
margin-top:0; }
.todo { font-family: monospace; color: red; }
.done { font-family: monospace; color: green; }
.priority { font-family: monospace; color: orange; }
.tag { background-color: #eee; font-family: monospace;
padding: 2px; font-size: 80%; font-weight: normal; }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
.underline { text-decoration: underline; }
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
p.verse { margin-left: 3%; }
pre {
border: 1px solid #e6e6e6;
border-radius: 3px;
background-color: #f2f2f2;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}
pre.src {
position: relative;
overflow: auto;
}
pre.src:before {
display: none;
position: absolute;
top: -8px;
right: 12px;
padding: 3px;
color: #555;
background-color: #f2f2f299;
}
pre.src:hover:before { display: inline; margin-top: 14px;}
/* Languages per Org manual */
pre.src-asymptote:before { content: 'Asymptote'; }
pre.src-awk:before { content: 'Awk'; }
pre.src-authinfo::before { content: 'Authinfo'; }
pre.src-C:before { content: 'C'; }
/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before { content: 'Clojure'; }
pre.src-css:before { content: 'CSS'; }
pre.src-D:before { content: 'D'; }
pre.src-ditaa:before { content: 'ditaa'; }
pre.src-dot:before { content: 'Graphviz'; }
pre.src-calc:before { content: 'Emacs Calc'; }
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
pre.src-fortran:before { content: 'Fortran'; }
pre.src-gnuplot:before { content: 'gnuplot'; }
pre.src-haskell:before { content: 'Haskell'; }
pre.src-hledger:before { content: 'hledger'; }
pre.src-java:before { content: 'Java'; }
pre.src-js:before { content: 'Javascript'; }
pre.src-latex:before { content: 'LaTeX'; }
pre.src-ledger:before { content: 'Ledger'; }
pre.src-lisp:before { content: 'Lisp'; }
pre.src-lilypond:before { content: 'Lilypond'; }
pre.src-lua:before { content: 'Lua'; }
pre.src-matlab:before { content: 'MATLAB'; }
pre.src-mscgen:before { content: 'Mscgen'; }
pre.src-ocaml:before { content: 'Objective Caml'; }
pre.src-octave:before { content: 'Octave'; }
pre.src-org:before { content: 'Org mode'; }
pre.src-oz:before { content: 'OZ'; }
pre.src-plantuml:before { content: 'Plantuml'; }
pre.src-processing:before { content: 'Processing.js'; }
pre.src-python:before { content: 'Python'; }
pre.src-R:before { content: 'R'; }
pre.src-ruby:before { content: 'Ruby'; }
pre.src-sass:before { content: 'Sass'; }
pre.src-scheme:before { content: 'Scheme'; }
pre.src-screen:before { content: 'Gnu Screen'; }
pre.src-sed:before { content: 'Sed'; }
pre.src-sh:before { content: 'shell'; }
pre.src-sql:before { content: 'SQL'; }
pre.src-sqlite:before { content: 'SQLite'; }
/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before { content: 'Forth'; }
pre.src-io:before { content: 'IO'; }
pre.src-J:before { content: 'J'; }
pre.src-makefile:before { content: 'Makefile'; }
pre.src-maxima:before { content: 'Maxima'; }
pre.src-perl:before { content: 'Perl'; }
pre.src-picolisp:before { content: 'Pico Lisp'; }
pre.src-scala:before { content: 'Scala'; }
pre.src-shell:before { content: 'Shell Script'; }
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before { content: 'C++'; }
pre.src-abc:before { content: 'ABC'; }
pre.src-coq:before { content: 'Coq'; }
pre.src-groovy:before { content: 'Groovy'; }
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before { content: 'bash'; }
pre.src-csh:before { content: 'csh'; }
pre.src-ash:before { content: 'ash'; }
pre.src-dash:before { content: 'dash'; }
pre.src-ksh:before { content: 'ksh'; }
pre.src-mksh:before { content: 'mksh'; }
pre.src-posh:before { content: 'posh'; }
/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before { content: 'Ada'; }
pre.src-asm:before { content: 'Assembler'; }
pre.src-caml:before { content: 'Caml'; }
pre.src-delphi:before { content: 'Delphi'; }
pre.src-html:before { content: 'HTML'; }
pre.src-idl:before { content: 'IDL'; }
pre.src-mercury:before { content: 'Mercury'; }
pre.src-metapost:before { content: 'MetaPost'; }
pre.src-modula-2:before { content: 'Modula-2'; }
pre.src-pascal:before { content: 'Pascal'; }
pre.src-ps:before { content: 'PostScript'; }
pre.src-prolog:before { content: 'Prolog'; }
pre.src-simula:before { content: 'Simula'; }
pre.src-tcl:before { content: 'tcl'; }
pre.src-tex:before { content: 'TeX'; }
pre.src-plain-tex:before { content: 'Plain TeX'; }
pre.src-verilog:before { content: 'Verilog'; }
pre.src-vhdl:before { content: 'VHDL'; }
pre.src-xml:before { content: 'XML'; }
pre.src-nxml:before { content: 'XML'; }
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before { content: 'Configuration File'; }
table { border-collapse:collapse; }
caption.t-above { caption-side: top; }
caption.t-bottom { caption-side: bottom; }
td, th { vertical-align:top; }
th.org-right { text-align: center; }
th.org-left { text-align: center; }
th.org-center { text-align: center; }
td.org-right { text-align: right; }
td.org-left { text-align: left; }
td.org-center { text-align: center; }
dt { font-weight: bold; }
.footpara { display: inline; }
.footdef { margin-bottom: 1em; }
.figure { padding: 1em; }
.figure p { text-align: center; }
.equation-container {
display: table;
text-align: center;
width: 100%;
}
.equation {
vertical-align: middle;
}
.equation-label {
display: table-cell;
text-align: right;
vertical-align: middle;
}
.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}
#org-div-home-and-up
{ text-align: right; font-size: 70%; white-space: nowrap; }
textarea { overflow-x: auto; }
.linenr { font-size: smaller }
.code-highlighted { background-color: #ffff00; }
.org-info-js_info-navigation { border-style: none; }
#org-info-js_console-label
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
.org-info-js_search-highlight
{ background-color: #ffff00; color: #000000; font-weight: bold; }
.org-svg { }
</style>
</head>
<body>
<div id="content" class="content">
<h1 class="title">SwarselSystems: NixOS + Emacs Configuration</h1>
<div id="table-of-contents" role="doc-toc">
<h2>Table of Contents</h2>
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="#h:a86fe971-f169-4052-aacf-15e0f267c6cd">1. Introduction (no code)</a></li>
<li><a href="#h:d39b8dfb-536d-414f-9fc0-7d67df48cee4">2. Noweb-Ref blocks</a>
<ul>
<li><a href="#h:237b9f25-1fa3-484e-952e-99175dbb91c5">2.1. Non-NixOS</a>
<ul>
<li><a href="#h:5bc1b0c9-dc59-4c81-b5b5-e60699deda78">2.1.1. Theme (stylix)</a></li>
<li><a href="#h:d9861165-2a10-44d9-831d-0fe23cc5473f">2.1.2. firefox profile</a></li>
</ul>
</li>
<li><a href="#h:996e9c5f-ed65-4f4f-b043-5a901ed74358">2.2. NixOS</a>
<ul>
<li><a href="#h:a4585ec3-8fa0-472c-a0db-1b34917591ea">2.2.1. Virtual hosts init</a></li>
</ul>
</li>
<li><a href="#h:c7588c0d-2528-485d-b2df-04d6336428d7">2.3. flake.nix</a>
<ul>
<li><a href="#h:8a411ee2-a58e-4b5b-99bd-4ba772f8f0a2">2.3.1. Inputs</a></li>
<li><a href="#h:df0072bc-853f-438f-bd85-bfc869501015">2.3.2. let</a></li>
<li><a href="#h:54cd8f65-a3ba-43c3-ae37-5f04383fe720">2.3.3. General (outputs)</a></li>
<li><a href="#h:9c9b9e3b-8771-44fa-ba9e-5056ae809655">2.3.4. nixosConfigurations</a></li>
<li><a href="#h:f881aa05-a670-48dd-a57b-2916abdcb692">2.3.5. homeConfigurations</a></li>
<li><a href="#h:5f6ef553-59f9-4239-b6f3-63d33b57f335">2.3.6. nixOnDroidConfigurations</a></li>
<li><a href="#h:6a08495a-8566-4bb5-9fac-b03df01f6c81">2.3.7. nixos-generators</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#h:02cd20be-1ffa-4904-9d5a-da5a89ba1421">3. System</a>
<ul>
<li><a href="#h:88bf4b90-e94b-46fb-aaf1-a381a512860d">3.1. System specific configuration</a>
<ul>
<li><a href="#h:58dc6384-0d19-4f71-9043-4014bd033ba2">3.1.1. Physical hosts</a></li>
<li><a href="#h:4dc59747-9598-4029-aa7d-92bf186d6c06">3.1.2. Virtual hosts</a></li>
</ul>
</li>
<li><a href="#h:ab272ab4-3c93-48b1-8f1e-f710aa9aae5d">3.2. Overlays, packages, and modules</a>
<ul>
<li><a href="#h:64a5cc16-6b16-4802-b421-c67ccef853e1">3.2.1. Packages</a></li>
<li><a href="#h:5e3e21e0-57af-4dad-b32f-6400af9b7aab">3.2.2. Overlays (additions, overrides, nixpkgs-stable)</a></li>
<li><a href="#h:f0f1c961-3e7a-47b8-99ab-1654bb45dffc">3.2.3. Modules</a></li>
</ul>
</li>
<li><a href="#h:6da812f5-358c-49cb-aff2-0a94f20d70b3">3.3. NixOS</a>
<ul>
<li><a href="#h:1c1250cd-e9b4-4715-8d9f-eb09e64bfc7f">3.3.1. Common</a></li>
<li><a href="#h:f9aa9af0-9b8d-43ff-901d-9ffccdd70589">3.3.2. Optional</a></li>
</ul>
</li>
<li><a href="#h:08ded95b-9c43-475d-a0b2-fc088a512287">3.4. Home-manager</a>
<ul>
<li><a href="#h:f0a6b5e0-2157-4522-b5e1-3f0abd91c05e">3.4.1. Common</a></li>
<li><a href="#h:be623200-557e-4bb7-bb11-1ec5d76c6b8b">3.4.2. Optional</a></li>
</ul>
</li>
<li><a href="#h:aee5ec75-7ca6-40d8-b6ac-a3e7e33a474b">3.5. flake.nix template</a>
<ul>
<li><a href="#h:4f89db68-a21c-415d-87a5-21c66f2b6ded">3.5.1. flake.nix</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#h:ed4cd05c-0879-41c6-bc39-3f1246a96f04">4. Emacs</a>
<ul>
<li><a href="#h:2c331451-45ed-4592-9e00-d36b5bf31248">4.1. Initialization (early-init.el)</a>
<ul>
<li><a href="#h:38e03b65-9dfc-4547-b27d-236664d7dc15">4.1.1. Increase startup performance</a></li>
<li><a href="#h:782b3632-afb2-4c67-8c46-ff94408aef5d">4.1.2. Setup frames</a></li>
<li><a href="#h:396c47f2-7e2f-4fad-ae71-6483bf7e3e42">4.1.3. Make C-i, C-m, C-[ available in graphic sessions</a></li>
</ul>
</li>
<li><a href="#h:601ba407-b906-4869-8ef6-67a9fc285fba">4.2. Personal settings</a>
<ul>
<li><a href="#h:b7b5976a-db2b-493d-8794-1924a0e12aec">4.2.1. Custom functions</a></li>
<li><a href="#h:2b827c27-0de7-45ed-9d9e-6c511e2c6bb5">4.2.2. Custom Keybindings</a></li>
<li><a href="#h:07951589-54ba-4e3e-bd7b-4106cd22ff6a">4.2.3. Directory setup / File structure</a></li>
<li><a href="#h:0cf30b76-91d9-41da-a10b-74199bc36d40">4.2.4. Unclutter .emacs.d</a></li>
<li><a href="#h:329f529a-ef9f-4787-b311-1c485e05b754">4.2.5. Move backup files to another location</a></li>
</ul>
</li>
<li><a href="#h:786b447d-03ad-4c1d-b114-c37caa2d591c">4.3. General init.el setup + UI</a>
<ul>
<li><a href="#h:76a5bd78-a20d-4068-bea8-a38fdb26428e">4.3.1. General setup</a></li>
<li><a href="#h:0debe8fd-b319-4ab7-a92c-784fa7896b75">4.3.2. Mark all themes as safe</a></li>
<li><a href="#h:b587e869-9911-443b-bc6d-8fb3ce31908d">4.3.3. Show less compilation warnings</a></li>
<li><a href="#h:6527b3ce-b76d-431a-9960-a57da7c53e1b">4.3.4. Indentation</a></li>
<li><a href="#h:3dc9fb1d-cd16-4bd0-a9ac-55a944415a90">4.3.5. Scrolling</a></li>
<li><a href="#h:5bf9f014-ee96-42da-b285-7b34f04e6bb1">4.3.6. Evil</a></li>
<li><a href="#h:e888d7a7-1755-4109-af11-5358b8cf140e">4.3.7. ispell</a></li>
<li><a href="#h:60f87342-0491-4c56-8057-6f075cf35753">4.3.8. Font Configuration</a></li>
<li><a href="#h:72a9704b-83d2-4b74-a1f6-d333203f62db">4.3.9. Theme</a></li>
<li><a href="#h:eb0ea526-a83a-4664-b3a1-2b40d3a31493">4.3.10. Icons</a></li>
<li><a href="#h:455ed7ac-ee7f-4f94-b857-f2c58b2282d0">4.3.11. Variable Pitch Mode</a></li>
<li><a href="#h:ed585848-875a-4673-910c-d2e1901dd95b">4.3.12. Modeline</a></li>
<li><a href="#h:39ae01e9-8053-4f76-aa77-8cbbbcff9652">4.3.13. Helper Modes</a></li>
<li><a href="#h:bbbd9cc8-3a84-4810-a3d5-b8536a5fbda1">4.3.14. Ligatures</a></li>
<li><a href="#h:e9d40e63-0e1f-47df-98f7-5427992588a4">4.3.15. Popup (popper) + Shackle Buffers</a></li>
<li><a href="#h:a6d23c8c-125f-4e36-af30-ff0a1e0d5a28">4.3.16. Indicate first and last line of buffer</a></li>
<li><a href="#h:053a36bf-168f-4f63-a0c4-f0139dc6cc3b">4.3.17. Authentication</a></li>
</ul>
</li>
<li><a href="#h:f2622fd3-7f14-47a8-8c21-33574fcbf14b">4.4. Modules</a>
<ul>
<li><a href="#h:99544398-72af-4382-b8e1-01b2221baff4">4.4.1. Org Mode</a></li>
<li><a href="#h:406c2ecc-0e3e-4d9f-9ae3-3eb1f8b87d1b">4.4.2. Nix Mode</a></li>
<li><a href="#h:5ca7484b-b9d6-4023-88d1-a1e37d5df249">4.4.3. nixpkgs-fmt</a></li>
<li><a href="#h:50327461-a11b-4e81-830a-90febc720cfa">4.4.4. Markdown Mode</a></li>
<li><a href="#h:65e69741-9860-4ed0-bbed-7b7be9a2a9d6">4.4.5. Olivetti</a></li>
<li><a href="#h:94d4a0dc-b0d7-4702-b760-beeaa6da2b8f">4.4.6. darkroom</a></li>
<li><a href="#h:87453f1c-8ea5-4d0a-862d-8973d5bc5405">4.4.7. Ripgrep</a></li>
<li><a href="#h:543641d0-02a9-459e-a2d6-96c8fcc06864">4.4.8. Tree-sitter</a></li>
<li><a href="#h:82ddeef2-99f8-465b-ba36-07c3eaad717b">4.4.9. direnv (envrc)</a></li>
<li><a href="#h:efb3f0fd-e846-4df9-ba48-2e45d776f68f">4.4.10. avy</a></li>
<li><a href="#h:1c1821c6-98de-4079-a4f3-6ba6e6dcb668">4.4.11. crdt (Collaborative Editing)</a></li>
<li><a href="#h:d9a6cb44-736e-4608-951f-e928e1b757c0">4.4.12. devdocs</a></li>
<li><a href="#h:5cde5032-251e-4cc4-9202-b4ce996f92c2">4.4.13. Projectile</a></li>
<li><a href="#h:d2c7323d-f8c6-4f23-b70a-930e3e4ecce5">4.4.14. Magit</a></li>
<li><a href="#h:d78709dd-4f79-441c-9166-76f61f90359a">4.4.15. Yubikey support</a></li>
<li><a href="#h:1a8585ed-d9f2-478f-a132-440ada1cde2c">4.4.16. Forge</a></li>
<li><a href="#h:cf5b0e6b-56a5-4a93-99fb-258eb7cb2eb4">4.4.17. git-timemachine</a></li>
<li><a href="#h:d9671ab7-a75a-47c6-a1f4-376d126c9b0a">4.4.18. Delimiters (brackets): rainbow-delimiters, highlight-parentheses</a></li>
<li><a href="#h:d1a32a69-2f9a-45ef-95fe-a00e3551dc94">4.4.19. rainbow-mode</a></li>
<li><a href="#h:5653d693-ecca-4c95-9633-66b9e3241070">4.4.20. Corfu</a></li>
<li><a href="#h:c3cc1c12-3ab8-42b7-be07-63f54eac397f">4.4.21. cape</a></li>
<li><a href="#h:3aa20438-edf6-4b13-a90d-3d5c51239c44">4.4.22. rust</a></li>
<li><a href="#h:b9b27a88-06f3-470b-a604-a20b2079bc26">4.4.23. Tramp</a></li>
<li><a href="#h:58415e95-8a7a-4517-acbb-5f1bb1028603">4.4.24. diff-hl</a></li>
<li><a href="#h:d60ce0b1-cabf-43f5-a236-a1e4b400d2f5">4.4.25. Commenting</a></li>
<li><a href="#h:9ec11ee4-2250-414a-87b5-73ee680a3a4a">4.4.26. yasnippet</a></li>
<li><a href="#h:316857e7-4df8-4ec5-b22e-6dac918fa937">4.4.27. eglot</a></li>
<li><a href="#h:1de35f27-335d-4cbd-beb6-f85cf5496173">4.4.28. Breadcrumb</a></li>
<li><a href="#h:e9a30d0f-423f-4e85-af4b-f8560f1c1b53">4.4.29. Prevent breaking of hardlinks</a></li>
<li><a href="#h:0918557a-8463-430c-b8df-6546dea9abd0">4.4.30. Dirvish</a></li>
<li><a href="#h:b108dd3e-f34d-4ed3-98df-0bf9de055889">4.4.31. pdf-tools: pdf-viewer and support for dirvish</a></li>
<li><a href="#h:c15efae7-b884-4c97-8367-ccc7e7ed9ba8">4.4.32. Jupyter</a></li>
<li><a href="#h:1fc538d1-8c53-48b2-8652-66046f4bbbf8">4.4.33. undo-tree</a></li>
<li><a href="#h:b6c18dd0-3377-47ea-80c3-ac1486454e18">4.4.34. Hydra</a></li>
<li><a href="#h:fff816a0-6d70-4bda-abab-833345e51100">4.4.35. External Applications</a></li>
<li><a href="#h:2f333330-b19d-4f64-85ea-146ff28667e8">4.4.36. Email</a></li>
<li><a href="#h:c760f04e-622f-4b3e-8916-53ca8cce6edc">4.4.37. Calendar</a></li>
<li><a href="#h:48f5be2b-b3d2-4276-bd49-2630733f23d5">4.4.38. Dashboard: emacs startup screen</a></li>
<li><a href="#h:672ddd5c-7679-44a2-9085-936e9198fc2b">4.4.39. ansible</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<p>
<b>This file has 45632 words spanning 12064 lines and was last revised on 2024-08-31 18:00:48 +0200.</b>
</p>
<p>
In order to have working links and macros when viewing this file online, you might want to switch to the <a href="https://swarsel.github.io/.dotfiles/">html version</a>.
</p>
<div id="outline-container-h:a86fe971-f169-4052-aacf-15e0f267c6cd" class="outline-2">
<h2 id="h:a86fe971-f169-4052-aacf-15e0f267c6cd"><span class="section-number-2">1.</span> Introduction (no code)</h2>
<div class="outline-text-2" id="text-h:a86fe971-f169-4052-aacf-15e0f267c6cd">
<p>
This literate configuration file holds the entirety of all configuration files for both NixOS as well as home manager across all machines that I currently use. It also holds an extensive Emacs configuration
</p>
<p>
I used to have two separate files (<code>Emacs.org</code> and <code>Nixos.org</code>) because the NixOS setting for installing Emacs packages used to break if it found UTF-8 characters in <code>.el</code> files but not in <code>.org</code> files. Hence I used to pass <code>Emacs.org</code> to that function rather than <code>init.el</code>. This seems to be fixed now however and I was finally able to consolidate both files into one.
</p>
<p>
This configuration is part of a NixOS system that is fully declarative and can be found here:
</p>
<ul class="org-ul">
<li><a href="https:github.com/Swarsel/.dotfiles"><code>SwarselSystems</code> on github.com</a></li>
<li><a href="https:swagit.swarsel.win/Swarsel/.dotfiles"><code>SwarselSystems</code> on swagit.swarsel.win</a></li>
</ul>
<p>
The literate configuration lets me explain my choices to my future self as well as you, the reader. I go to great lengths to explain the choices for all configuration steps that I take in order for me to pay due diligence in crafting my setup, and not simply copying big chunks of other peoples code. Also, the literate configuration approach is very convenient to me as I only need to keep of (ideally) a single file to manage all of my configuration. I hope that this documentation will make it easier for beginners to get into Emacs and NixOS as I know it can be a struggle in the beginning.
</p>
<p>
This file is structured as follows:
</p>
<ul class="org-ul">
<li><a href="#h:a86fe971-f169-4052-aacf-15e0f267c6cd">Introduction (no code)</a>
This is the block you are currently in. It holds no code that actually builds the system, it just outlines the general approach and explains my rough mentality</li>
<li><a href="#h:d39b8dfb-536d-414f-9fc0-7d67df48cee4">Noweb-Ref blocks</a>
This section hold code that can be templated at other parts of the configuration. This is mostly used for the NixOS side of the configuration where I define my host systems that usually have a lot in common.</li>
<li><a href="#h:02cd20be-1ffa-4904-9d5a-da5a89ba1421">System</a>
This section holds all configuration options that apply to NixOS or Home Manager. In other words, here we are doing system and user level configuration.</li>
<li><p>
<a href="#h:ed4cd05c-0879-41c6-bc39-3f1246a96f04">Emacs</a>
This section defines my Emacs configuration. For a while, I considered to use rycee's <code>emacs-init</code> module (<a href="https://github.com/nix-community/nur-combined/blob/master/repos/rycee/hm-modules/emacs-init.nix">https://github.com/nix-community/nur-combined/blob/master/repos/rycee/hm-modules/emacs-init.nix</a>) to manage my Emacs configuration; I have since come to the conclusion that this would be a bad idea: at the moment, even though it might seem as I am very bound to the configuration file that you are currently reading, if I ever decide to change how I run my system, I can simply take the generated <code>.nix</code> and <code>.el</code> files and put them wherever I need them. This file only simplifies that generation without putting further restrictions on my. If I were however to switch to <code>emacs-init</code> then I would be indeed to some level confined to the nix ecosystem with my Emacs configuration, as I would no longer have a valid <code>.org</code> file to manage it with, instead generating an <code>init.el</code> directly from nix code. I like to keep that level of freedom for potential future use. Also, you will notice there is no package system setup in this configuration. This is because packages are automatically handled on the NixOS side by parsing the generated <code>init.el</code> file for package installs.
</p>
<p>
My emacs is built using the emacs-overlay nix flake, which builds a bleeding edge emacs on wayland (pgtk) with utilities like treesitter support. By executing the below source block, the current build setting can be updated at any time, and you can see my most up-to-date build options (last updated: 2024-08-31 18:00:48 +0200)
</p></li>
</ul>
<div class="org-src-container">
<pre class="src src-emacs-lisp">
system-configuration-options
</pre>
</div>
<pre class="example">
--prefix=/nix/store/bjzr50zcpb5dqwybljizsvzs7pzx3jk5-emacs-pgtk-20240827.0 --disable-build-details --with-modules --with-pgtk --with-compress-install --with-toolkit-scroll-bars --with-native-compilation --without-imagemagick --with-mailutils --without-small-ja-dic --with-tree-sitter --without-xinput2 --with-xwidgets --with-dbus --with-selinux
</pre>
<p>
This file is not loaded by Emacs directly as the configuration (even though this would be possible) - instead, it generates two more files:
</p>
<ul class="org-ul">
<li><code>early-init.el</code>
This file handle startup optimization and sets up the basic frame that I will be working in.</li>
<li><code>init.el</code>
This file handles the rest of the Emacs configuration.</li>
</ul>
<p>
By using the configuration offered by this file, the file you are reading right now (<code>SwarselSystems.org</code>) will be freshly tangled on every file save. However, when you clone this configuration yourself and have not yet activated it, you need to tangle the file yourself. This can be done using the keybind <code>C-c C-v t</code>. Alternatively, execute the following block:
</p>
<div class="org-src-container">
<pre class="src src-emacs-lisp">
(org-babel-tangle)
</pre>
</div>
<p>
Lastly, I add this javascript bit to the file in order to have a darkmode toggle when exporting to html:
</p>
<div class="org-src-container">
<pre class="src src-elisp">(concat
"<script src=\"https://cdn.jsdelivr.net/npm/darkmode-js@1.5.7/lib/darkmode-js.min.js\"></script>\n"
"<script>\n"
"function addDarkmodeWidget() {\n"
"new Darkmode().showWidget();\n"
"}\n"
"window.addEventListener('load', addDarkmodeWidget);\n"
"</script>")
</pre>
</div>
<script src="https://cdn.jsdelivr.net/npm/darkmode-js@1.5.7/lib/darkmode-js.min.js"></script>
<script>
function addDarkmodeWidget() {
new Darkmode().showWidget();
}
window.addEventListener('load', addDarkmodeWidget);
</script>
<p>
The rest of this file will now contain actual code that is used in the configuration.
</p>
</div>
</div>
<div id="outline-container-h:d39b8dfb-536d-414f-9fc0-7d67df48cee4" class="outline-2">
<h2 id="h:d39b8dfb-536d-414f-9fc0-7d67df48cee4"><span class="section-number-2">2.</span> Noweb-Ref blocks</h2>
<div class="outline-text-2" id="text-h:d39b8dfb-536d-414f-9fc0-7d67df48cee4">
<p>
These blocks are used in several places throughout the configurations, but not on all machines necessarily. For example, the theming section needs to be in a NixOS block on NixOS machines but in a home-manager block on non-NixOS. This serves to reduce code duplication.
</p>
</div>
<div id="outline-container-h:237b9f25-1fa3-484e-952e-99175dbb91c5" class="outline-3">
<h3 id="h:237b9f25-1fa3-484e-952e-99175dbb91c5"><span class="section-number-3">2.1.</span> Non-NixOS</h3>
<div class="outline-text-3" id="text-h:237b9f25-1fa3-484e-952e-99175dbb91c5">
<p>
These blocks are to be used on systems that are not running NixOS. For example, one such system would be a Fedora system running home manager, where the respective NixOS features might not be available.
</p>
</div>
<div id="outline-container-h:5bc1b0c9-dc59-4c81-b5b5-e60699deda78" class="outline-4">
<h4 id="h:5bc1b0c9-dc59-4c81-b5b5-e60699deda78"><span class="section-number-4">2.1.1.</span> Theme (stylix)</h4>
<div class="outline-text-4" id="text-h:5bc1b0c9-dc59-4c81-b5b5-e60699deda78">
<p>
This is where the theme for the whole OS is defined. This noweb-ref section cannot be copied to the general NixOS config for now since they are on different folder structure levels in the config, which would make the flake impure.
</p>
<p>
For styling, I am using the <a href="https://github.com/danth/stylix">stylix</a> NixOS module, loaded by flake. This package is really great, as it adds nix expressions for basically everything. Ever since switching to this, I did not have to play around with theming anywhere else.
</p>
<div class="org-src-container">
<pre class="src src-nix">
enable = true;
base16Scheme = ../../../wallpaper/swarsel.yaml;
# base16Scheme = "${pkgs.base16-schemes}/share/themes/shapeshifter.yaml";
polarity = "dark";
opacity.popups = 0.5;
cursor = {
package = pkgs.capitaine-cursors;
name = "capitaine-cursors";
size = 16;
};
fonts = {
sizes = {
terminal = 10;
applications = 11;
};
serif = {
# package = (pkgs.nerdfonts.override { fonts = [ "FiraMono" "FiraCode"]; });
package = pkgs.cantarell-fonts;
# package = pkgs.montserrat;
name = "Cantarell";
# name = "FiraCode Nerd Font Propo";
# name = "Montserrat";
};
sansSerif = {
# package = (pkgs.nerdfonts.override { fonts = [ "FiraMono" "FiraCode"]; });
package = pkgs.cantarell-fonts;
# package = pkgs.montserrat;
name = "Cantarell";
# name = "FiraCode Nerd Font Propo";
# name = "Montserrat";
};
monospace = {
package = pkgs.nerdfonts; # has overrides
name = "FiraCode Nerd Font Mono";
};
emoji = {
package = pkgs.noto-fonts-emoji;
name = "Noto Color Emoji";
};
};
</pre>
</div>
</div>
</div>
<div id="outline-container-h:d9861165-2a10-44d9-831d-0fe23cc5473f" class="outline-4">
<h4 id="h:d9861165-2a10-44d9-831d-0fe23cc5473f"><span class="section-number-4">2.1.2.</span> firefox profile</h4>
<div class="outline-text-4" id="text-h:d9861165-2a10-44d9-831d-0fe23cc5473f">
<p>
At work I am using several services that are using SSO login - however, as I am using four different accounts at work, this becomes a chore here. Hence, I have defined multiple profiles in <a href="#h:f0b2ea93-94c8-48d8-8d47-6fe58f58e0e6">Work</a> that are all practically using the same configuration. To save screen space, I template that profile here.
</p>
<div class="org-src-container">
<pre class="src src-nix">
isDefault = false;
userChrome = builtins.readFile ../../../programs/firefox/chrome/userChrome.css;
extensions = with pkgs.nur.repos.rycee.firefox-addons; [
tridactyl
browserpass
clearurls
darkreader
enhancer-for-youtube
istilldontcareaboutcookies
translate-web-pages
ublock-origin
reddit-enhancement-suite
sponsorblock
web-archives
onepassword-password-manager
single-file
widegithub
enhanced-github
unpaywall
don-t-fuck-with-paste
plasma-integration
];
search.engines = {
"Nix Packages" = {
urls = [{
template = "https://search.nixos.org/packages";
params = [
{ name = "type"; value = "packages"; }
{ name = "query"; value = "{searchTerms}"; }
];
}];
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
definedAliases = [ "@np" ];
};
"NixOS Wiki" = {
urls = [{
template = "https://nixos.wiki/index.php?search={searchTerms}";
}];
iconUpdateURL = "https://nixos.wiki/favicon.png";
updateInterval = 24 * 60 * 60 * 1000; # every day
definedAliases = [ "@nw" ];
};
"NixOS Options" = {
urls = [{
template = "https://search.nixos.org/options";
params = [
{ name = "query"; value = "{searchTerms}"; }
];
}];
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
definedAliases = [ "@no" ];
};
"Home Manager Options" = {
urls = [{
template = "https://home-manager-options.extranix.com/";
params = [
{ name = "query"; value = "{searchTerms}"; }
];
}];
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
definedAliases = [ "@hm" "@ho" "@hmo" ];
};
"Google".metaData.alias = "@g";
};
search.force = true; # this is required because otherwise the search.json.mozlz4 symlink gets replaced on every firefox restart
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-h:996e9c5f-ed65-4f4f-b043-5a901ed74358" class="outline-3">
<h3 id="h:996e9c5f-ed65-4f4f-b043-5a901ed74358"><span class="section-number-3">2.2.</span> NixOS</h3>
<div class="outline-text-3" id="text-h:996e9c5f-ed65-4f4f-b043-5a901ed74358">
<p>
These settings are to be used only on full NixOS setups.
</p>
</div>
<div id="outline-container-h:a4585ec3-8fa0-472c-a0db-1b34917591ea" class="outline-4">
<h4 id="h:a4585ec3-8fa0-472c-a0db-1b34917591ea"><span class="section-number-4">2.2.1.</span> Virtual hosts init</h4>
<div class="outline-text-4" id="text-h:a4585ec3-8fa0-472c-a0db-1b34917591ea">
<p>
This sections is for common NixoS settings that I use for my NixoS LXC images that I run on Proxmox. Proxmox requires special attention to run along with NixOS in any capacity.
</p>
<div class="org-src-container">
<pre class="src src-nix">
services = {
xserver.xkb = {
layout = "us";
variant = "altgr-intl";
};
openssh = {
enable = true;
settings.PermitRootLogin = "yes";
listenAddresses = [{
port = 22;
addr = "0.0.0.0";
}];
};
};
nix.settings.experimental-features = [ "nix-command" "flakes" ];
proxmoxLXC = {
manageNetwork = true; # manage network myself
manageHostName = false; # manage hostname myself
};
networking = {
useDHCP = true;
enableIPv6 = false;
};
users.users.root.openssh.authorizedKeys.keyFiles = [
../../../secrets/keys/authorized_keys
];
system.stateVersion = "23.05"; # TEMPLATE - but probably no need to change
environment.shellAliases = {
nswitch = "cd /.dotfiles; git pull; nixos-rebuild --flake .#$(hostname) switch; cd -;";
};
</pre>
</div>
<p>
This is again the <code>hardware-configuration.nix</code> wrap that you saw earlier, however for Proxmox systems we need to add some more NixOS modules for compatibility.
</p>
<div class="org-src-container">
<pre class="src src-nix">
imports = [
(modulesPath + "/virtualisation/proxmox-lxc.nix")
./hardware-configuration.nix
];
services = {
xserver.xkb = {
layout = "us";
variant = "altgr-intl";
};
openssh = {
enable = true;
settings.PermitRootLogin = "yes";
listenAddresses = [{
port = 22;
addr = "0.0.0.0";
}];
};
};
nix.settings.experimental-features = [ "nix-command" "flakes" ];
proxmoxLXC = {
manageNetwork = true; # manage network myself
manageHostName = false; # manage hostname myself
};
networking = {
useDHCP = true;
enableIPv6 = false;
};
users.users.root.openssh.authorizedKeys.keyFiles = [
../../../secrets/keys/authorized_keys
];
system.stateVersion = "23.05"; # TEMPLATE - but probably no need to change
environment.shellAliases = {
nswitch = "cd /.dotfiles; git pull; nixos-rebuild --flake .#$(hostname) switch; cd -;";
};
</pre>
</div>
</div>
</div>
</div>
<div id="outline-container-h:c7588c0d-2528-485d-b2df-04d6336428d7" class="outline-3">
<h3 id="h:c7588c0d-2528-485d-b2df-04d6336428d7"><span class="section-number-3">2.3.</span> flake.nix</h3>
<div class="outline-text-3" id="text-h:c7588c0d-2528-485d-b2df-04d6336428d7">
<p>
Handling the flake.nix file used to be a bit of a chore, since it felt like writing so much boilerplate code just to define new systems. The noweb-approach here makes this a little bit less painful.
</p>
<p>
These blocks are later inserted here: <a href="#h:aee5ec75-7ca6-40d8-b6ac-a3e7e33a474b">flake.nix template</a>. Adding new flake inputs is very easy, you just add them to <a href="#h:8a411ee2-a58e-4b5b-99bd-4ba772f8f0a2">Inputs & Inputs@Outputs</a> first by name in the first source-block, and then the path in the second source-block. Any variables to be set for the host configuration are done in <a href="#h:df0072bc-853f-438f-bd85-bfc869501015">let</a>, and the specific setup is done in either <a href="#h:9c9b9e3b-8771-44fa-ba9e-5056ae809655">nixosConfigurations</a> (for NixOS systems), <a href="#h:f881aa05-a670-48dd-a57b-2916abdcb692">homeConfigurations</a> (for home-manager systems), or <a href="#h:5f6ef553-59f9-4239-b6f3-63d33b57f335">nixOnDroidConfigurations</a> (for Nix on Android). There is also the <a href="#h:6a08495a-8566-4bb5-9fac-b03df01f6c81">nixos-generators</a> section that currently just defines a Proxmox LXC image.
</p>
</div>
<div id="outline-container-h:8a411ee2-a58e-4b5b-99bd-4ba772f8f0a2" class="outline-4">
<h4 id="h:8a411ee2-a58e-4b5b-99bd-4ba772f8f0a2"><span class="section-number-4">2.3.1.</span> Inputs</h4>
<div class="outline-text-4" id="text-h:8a411ee2-a58e-4b5b-99bd-4ba772f8f0a2">
<p>
Here we define inputs and outputs of the flake. First, the following list is for the outputs of the flake.
</p>
<p>
Format: <name>,
</p>
<p>
Mind the comma at the end. You need this because the <code>...</code> is being passed as the last argument in the template at <a href="#h:aee5ec75-7ca6-40d8-b6ac-a3e7e33a474b">flake.nix template</a>.
</p>
<p>
Here, just add the input names, urls and other options that are needed, like <code>nixpkgs.follows</code>. By using the latter option, you tell the package to not provide it's own package repository, but instead 'nest' itself into another, which is very useful.
A short overview over each input and what it does:
</p>
<ul class="org-ul">
<li><a href="https://github.com/NixOS/nixpkgs">nixpkgs</a>
This is the base repository that I am following for all packages. I follow the unstable branch.</li>
<li><a href="https://github.com/nix-community/home-manager">home-manager</a>
This handles user-level configuration and mostly provides dotfiles that are generated and symlinked to <code>~/.config/</code>.</li>
<li><a href="https://github.com/nix-community/NUR">NUR</a>
The nix user repository contains user provided modules, packages and expressions. These are not audited by the nix community, so be aware of supply chain vulnerabilities when using those. I am only really using rycee's firefox addons from there which saves me a lot of hassle, and it seems to be a safe resource.</li>
<li><a href="https://github.com/nix-community/nixGL">nixGL</a>
This solves the problem that nix has with "OpenGL", as libraries are not linked and programs will often fail to find drivers. But I do not fully understand what it does. All I know is that I usually have to use this on non-NIxoS systems.</li>
<li><a href="https://github.com/danth/stylix">stylix</a>
As described before, this handles all theme related options.</li>
<li><a href="https://github.com/Mic92/sops-nix">sops-nix</a>
This provides declarative secrets management for NixOS and home manager using sops and age keys. It is a bit more cumbersome to use on home manager systems - which is a bother because I then have to resort to that configuration to keep everything supported - but it is super practical and really the primary reason why it makes sense for me to go for NixOS, as I do not have to do any extra secrets provisioning.</li>
<li><a href="https://github.com/nix-community/lanzaboote">Lanzaboote</a>
Provides secure boot for NixOS. Needed for my Surface Pro 3.</li>
<li><a href="https://github.com/nix-community/nix-on-droid">nix-on-droid</a>
This brings nix to android in an app that is similar to tmux! Of course most of the configuration does not apply to this, but it is still neat to have!</li>
<li><a href="https://github.com/NixOS/nixos-hardware">nixos-hardware</a>
Provides specific hardware setting for some hardware configurations. For example, this sets some better defaults for my Lenovo Thinkpad P14s Gen2.</li>
<li><a href="https://github.com/thiagokokada/nix-alien">nix-alien</a>
This is supposed to allow me to run unpatched libraries directly without a need for ELF patching or resorting to <code>steam-run</code>. However, I have not yet gotten this to work.</li>
<li><a href="https://github.com/nix-community/nixos-generators">nixos-generators</a>
Provides me with images that I can use to create LXCs on Proxmox.</li>
<li><a href="https://github.com/Swarsel/nswitch-rcm-nix">nswitch-rcm-nix</a>
Allows auto injection of payloads upon connecting a Nintendo Switch.</li>
<li><a href="https://github.com/nix-community/nix-index-database">nix-index-database</a>
This provides a database for <code>nix-index</code> that is updated weekly. This allows for declarative management, without needing to run the <code>nix-index</code> command for database assembly.</li>
<li><a href="https://github.com/nix-community/disko">disko</a>
disko provides declarative disk partitioning, which I use for impermanence as well as <a href="https://github.com/nix-community/nixos-anywhere">nixos-anywhere</a>.</li>
<li><a href="https://github.com/nix-community/impermanence">Impermanence</a>
Some of my machines are using a btrfs filesystem that wipes the root directory on each reboot. This forces me to pay more attention in keeping my system declarative as well as helping me keeping the system uncluttered. However, it is a chore to make sure that important files are not deleted. This flake helps with this problem, allowing me to select files and directories for persisting.</li>
</ul>
<div class="org-src-container">
<pre class="src src-nix">
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
systems.url = "github:nix-systems/default-linux";
# user-level configuration
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
# overlay to access bleeding edge emacs
emacs-overlay = {
url = "github:nix-community/emacs-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
# nix user repository
# i use this mainly to not have to build all firefox extensions
# myself as well as for the emacs-init package (tbd)
nur.url = "github:nix-community/NUR";
# provides GL to non-NixOS hosts
nixgl.url = "github:guibou/nixGL";
# manages all theming using Home-Manager
stylix.url = "github:danth/stylix";
# nix secrets management
sops-nix.url = "github:Mic92/sops-nix";
# enable secure boot on NixOS
lanzaboote.url = "github:nix-community/lanzaboote";
# nix for android
nix-on-droid = {
url = "github:t184256/nix-on-droid/release-23.05";
inputs.nixpkgs.follows = "nixpkgs";
};
# generate NixOS images
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
# hardware quirks on nix
nixos-hardware = {
url = "github:NixOS/nixos-hardware/master";
};
# dynamic library loading
nix-alien = {
url = "github:thiagokokada/nix-alien";
};
# automatic nintendo switch payload injection
nswitch-rcm-nix = {
url = "github:Swarsel/nswitch-rcm-nix";
};
# weekly updated nix-index database
nix-index-database = {
url = "github:nix-community/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
impermanence.url = "github:nix-community/impermanence";
</pre>
</div>
</div>
</div>
<div id="outline-container-h:df0072bc-853f-438f-bd85-bfc869501015" class="outline-4">
<h4 id="h:df0072bc-853f-438f-bd85-bfc869501015"><span class="section-number-4">2.3.2.</span> let</h4>
<div class="outline-text-4" id="text-h:df0072bc-853f-438f-bd85-bfc869501015">
<p>
Here I define a few variables that I need for my system specifications. First and foremost, <code>pkgs</code>, which gets passed the emacs-overlay, nur, and nixgl modules to it. With this, I can grab all these packages by referencing <code>pkgs.<name></code> instead of having to put e.g. <code>nixgl.auto.nixGLDefault</code>.
</p>
<p>
Lastly I define some common module lists that I can simply load depending on the fundamental system (NixOS vs. non-NixOS).
</p>
<div class="org-src-container">
<pre class="src src-nix">inherit (self) outputs;
lib = nixpkgs.lib // home-manager.lib;
forEachSystem = f: lib.genAttrs (import systems) (system: f pkgsFor.${system});
pkgsFor = lib.genAttrs (import systems) (
system:
import nixpkgs {
inherit system;
config.allowUnfree = true;
}
);
# NixOS modules that can only be used on NixOS systems
nixModules = [
inputs.stylix.nixosModules.stylix
inputs.lanzaboote.nixosModules.lanzaboote
inputs.disko.nixosModules.disko
# inputs.impermanence.nixosModules.impermanence
inputs.sops-nix.nixosModules.sops
inputs.nswitch-rcm-nix.nixosModules.nswitch-rcm
./profiles/common/nixos
];
# Home-Manager modules wanted on non-NixOS systems
homeModules = [
inputs.stylix.homeManagerModules.stylix
];
# Home-Manager modules wanted on both NixOS and non-NixOS systems
mixedModules = [
inputs.sops-nix.homeManagerModules.sops
inputs.nix-index-database.hmModules.nix-index
./profiles/common/home
];
</pre>
</div>
</div>
</div>
<div id="outline-container-h:54cd8f65-a3ba-43c3-ae37-5f04383fe720" class="outline-4">
<h4 id="h:54cd8f65-a3ba-43c3-ae37-5f04383fe720"><span class="section-number-4">2.3.3.</span> General (outputs)</h4>
<div class="outline-text-4" id="text-h:54cd8f65-a3ba-43c3-ae37-5f04383fe720">
<p>
In this section I am creating some attributes that define general concepts of my configuration:
</p>
<ul class="org-ul">
<li><code>nixosModules</code> imports self-defined options that I only want to use on NixOS systems. All modules are held as separately as possible, to allow for easier sharing with other people mostly.</li>
<li><code>homeManagerModules</code> imports modules that are to be used on NixOS and non-NixOS systems. These are mostly used to define outputs (monitors), keyboards and special commands for machines.</li>
<li><code>packages</code> holds packages that I am building myself. These are mostly shell scripts, but also a few others such as AppImages and firefox addons.</li>
<li><code>devShells</code> provides a development shell that can be used as a bootstrap for new installs using <code>nix develop</code> while inside the flake directory.</li>
<li><code>formatter</code> provides the formatter that is to be used on <code>.nix</code> files. At the moment this is not used anywhere.</li>
<li><code>overlays</code> imports a few community overlays (such as the emacs-overlay) and also three overlays of my own:
<ol class="org-ol">
<li><code>additions</code> holds derivations that I am adding myself to nixpkgs - i.e. this is where the packages defined in <code>/pkgs</code> get added to nixpkgs.</li>
<li><code>modifications</code> holds derivations that I have performed overrides on. The list of interesting attribute overrides can be found by looking at the source code of a derivation and looking at the start of the file for lines of the form <code><name> ? <val></code>. But this can also be used to, for example, fetch a different version of a package instead.</li>
<li><code>nixpkgs-stable</code> holds the newest version of stable nixpkgs. I only use this on packages that seem broken on unstable, which are not many.</li>
</ol></li>
</ul>
<div class="org-src-container">
<pre class="src src-nix">
inherit lib;
inherit mixedModules;
nixosModules = import ./modules/nixos;
homeManagerModules = import ./modules/home;
packages = forEachSystem (pkgs: import ./pkgs { inherit pkgs; });
devShells = forEachSystem
(pkgs:
{
default = pkgs.mkShell {
NIX_CONFIG = "experimental-features = nix-command flakes";
nativeBuildInputs = [ pkgs.nix pkgs.home-manager pkgs.git ];
};
});
formatter = forEachSystem (pkgs: pkgs.nixpkgs-fmt);
overlays = [
(import ./overlays { inherit inputs; }).additions
(import ./overlays { inherit inputs; }).modifications
(import ./overlays { inherit inputs; }).nixpkgs-stable
inputs.nur.overlay
inputs.emacs-overlay.overlay
inputs.nixgl.overlay
];
</pre>
</div>
</div>
</div>
<div id="outline-container-h:9c9b9e3b-8771-44fa-ba9e-5056ae809655" class="outline-4">
<h4 id="h:9c9b9e3b-8771-44fa-ba9e-5056ae809655"><span class="section-number-4">2.3.4.</span> nixosConfigurations</h4>
<div class="outline-text-4" id="text-h:9c9b9e3b-8771-44fa-ba9e-5056ae809655">
<p>
This section used to be much longer, since I performed all of my imports right here in the past. Since then, I have however refactored and now my important hosts can be defined in little space. Once I have fully transitioned my server to NixOS too this section will become even smaller once more.
</p>