-
Notifications
You must be signed in to change notification settings - Fork 1
/
base-system.scm
360 lines (337 loc) · 12.7 KB
/
base-system.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
(define-module (system-config system base-system)
#:use-module (guix derivations)
#:use-module (guix store)
#:use-module (gnu)
#:use-module (srfi srfi-1)
#:use-module (gnu system nss)
#:use-module (gnu services admin)
#:use-module (gnu services pm)
#:use-module (gnu services dns)
#:use-module (gnu services cups)
#:use-module (gnu services mcron)
#:use-module (gnu services desktop)
#:use-module (gnu services docker)
#:use-module (gnu services networking)
#:use-module (gnu services virtualization)
#:use-module (gnu services linux)
#:use-module (gnu services vpn)
#:use-module (gnu services sound)
#:use-module (gnu services xorg)
#:use-module (gnu packages android)
#:use-module (gnu packages wm)
#:use-module (gnu packages libusb)
#:use-module (gnu packages cups)
#:use-module (gnu packages vpn)
#:use-module (gnu packages pdf)
#:use-module (gnu packages chromium)
#:use-module (gnu packages gnupg)
#:use-module (gnu packages password-utils)
#:use-module (gnu packages vim)
#:use-module (gnu packages android)
#:use-module (gnu packages tmux)
#:use-module (gnu packages video)
#:use-module (gnu packages suckless)
#:use-module (gnu packages chromium)
#:use-module (gnu packages terminals)
#:use-module (gnu packages file-systems)
#:use-module (gnu packages libreoffice)
#:use-module (gnu packages gtk)
#:use-module (gnu packages xorg)
#:use-module (gnu packages xdisorg)
#:use-module (gnu packages emacs)
#:use-module (gnu packages xdisorg)
#:use-module (gnu packages gnome)
#:use-module (gnu packages mtools)
#:use-module (gnu packages linux)
#:use-module (endgame packages librealsense)
#:use-module (endgame utils)
#:use-module (gnu packages audio)
#:use-module (gnu packages video)
#:use-module (gnu packages pdf)
#:use-module (gnu packages libreoffice)
#:use-module (gnu packages gnuzilla)
#:use-module (gnu packages pulseaudio)
#:use-module (gnu packages web-browsers)
#:use-module (gnu packages version-control)
#:use-module (gnu packages version-control)
#:use-module (guix derivations)
#:use-module (guix gexp)
#:use-module (guix store)
#:use-module (endgame packages librealsense)
#:use-module (endgame packages i3lock-blur)
#:use-module (gnu services security-token)
#:use-module (gnu packages package-management)
#:use-module (nongnu packages linux)
#:use-module (nongnu system linux-initrd)
#:export (base-operating-system)
#:export (wire-vpn))
(use-service-modules virtualization security-token)
(use-service-modules nix)
(use-service-modules desktop xorg)
(use-package-modules certs)
(use-package-modules shells)
;; https://github.com/Millak/guix-config/tree/master/config
(define %phodina-ssh-key
(plain-file "id_rsa.pub"
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDg/3m4MUAmsXyDrFcCtAMmg90NZwRIKMhhlk59V+CxdQy3IrKi5Xp3bqXr1hm0Z7nAFdBKEenK5nXSeuwzf3On43QAZoRbsm0/8J/5BZ+4nfpQ0iCZaSsbDR1eb6Qvcxnth5EeGJDNEaMDDCriM0v6lnDHCzJpIpMKC1cZd+bE4nEBhKQPxKs+/1DFV76GuTG0IQqHrq2HTQmm03zcuH/tg7if5tMWbJW1FXrZNyvtHl8VwdpRo4n8bLiIK8x8mJvnm6USCxmbI/M7nBvX5jwEJ1BOSzBRs+r7LRZ4bGneaoWBSyKgTMFAB9xGp1q0BUx26k7Gh2Bocl1A14oJIjnQ3QRmz+ZMIjtfObLdLaC5WoP6N++ienDOLH4Uxc8AmaJaBso9jseeaieGh3+NnfpqZ5QCN5J024zal0YCkvdebib1Xpy5MTnDaU9TRIQmLyNfyzyu9oD7GmW2HRbCBKFUWFUw/pbHtzSTJmZoj2+uEAVXqXu2adPD5jG3SXWAdELEKOtFK/PsgqLUPR6Gg/WCBfdKdER4XYgDyo+23TZ7LnbkToQY1xh+aQ9eNcHd/ArM3VBUl7ONU2sn36qS+1ELCr65YDVKDkUQm8S+OR098/RqvnDHnj3MhRgr4WteId8f3CHckpj8JA+UTc3a5r95HYDhglknk+JvYR+8DiqVKw== cardno:000611077967"))
;; Allow members of the "video" group to change the screen brightness.
(define %backlight-udev-rule
(udev-rule
"90-backlight.rules"
(string-append "ACTION==\"add\", SUBSYSTEM==\"backlight\", "
"RUN+=\"/run/current-system/profile/bin/chgrp video /sys/class/backlight/%k/brightness\""
"\n"
"ACTION==\"add\", SUBSYSTEM==\"backlight\", "
"RUN+=\"/run/current-system/profile/bin/chmod g+w /sys/class/backlight/%k/brightness\"")))
(define %librealsense-path
(let* ((librealsense-drv (with-store store
(run-with-store store (lower-object librealsense))))
(librealsense-store-path (derivation->output-path librealsense-drv)))
librealsense-store-path))
(define %my-desktop-services
(modify-services %desktop-services
(elogind-service-type config =>
(elogind-configuration (inherit config)
(handle-lid-switch-external-power 'suspend)))
(udev-service-type config =>
(udev-configuration (inherit config)
(rules (append (list librealsense
%backlight-udev-rule)
(udev-configuration-rules config)))))
(network-manager-service-type config =>
(network-manager-configuration (inherit config)
(dns "dnsmasq")
(vpn-plugins
(list
network-manager-openconnect))))))
(define %xorg-intel-screen-tearing-fix
"Section \"Device\"
Identifier \"Intel Graphics\"
Driver \"intel\"
Option \"AccelMethod\" \"sna\"
Option \"TearFree\" \"true\"
EndSection")
(define %xorg-enable-dri3
"Section \"Device\"
Identifier \"Intel Graphics\"
Driver \"intel\"
Option \"DRI\" \"3\"
EndSection")
(define %xorg-libinput-config
"Section \"InputClass\"
Identifier \"Touchpads\"
Driver \"libinput\"
MatchDevicePath \"/dev/input/event*\"
MatchIsTouchpad \"on\"
Option \"Tapping\" \"on\"
Option \"TappingDrag\" \"on\"
Option \"DisableWhileTyping\" \"on\"
Option \"MiddleEmulation\" \"on\"
Option \"ScrollMethod\" \"twofinger\"
EndSection
Section \"InputClass\"
Identifier \"Keyboards\"
Driver \"libinput\"
MatchDevicePath \"/dev/input/event*\"
MatchIsKeyboard \"on\"
EndSection
")
(define %endgame-directory "/home/cylon2p0/endgame/")
(define %garbage-collector-job-system
;; Collect garbage 5 minutes after midnight every day.
;; The job's action is a shell command.
#~(job "5 0 * * *" ;Vixie cron syntax
"guix system delete-generations 1w"))
(define-public base-operating-system
(operating-system
(timezone "Europe/Prague")
(locale "en_US.utf8")
(host-name "rocinante")
;; Use non-free Linux and firmware
(kernel linux)
; NOTE: To get the offset run `sudo filefrag -v /swap/swapfile`
;(kernel-arguments '("mem_sleep_default=deep" "resume=/swap/swapfile" "resume_offset=xxxx" "quiet"))
(firmware (list linux-firmware))
(initrd microcode-initrd)
;; Choose US and CZ qwerty keyboard layout. Switch between"
;; layout using Win + Space keys. Swap Ctrl and Tab
;(keyboard-layout (keyboard-layout "us,cz" "qwerty,"
; #:options '("grp:win_space_toggle" "ctrl:nocaps")))
;; Use the UEFI variant of GRUB with the EFI System
;; Partition mounted on /boot/efi
(bootloader (bootloader-configuration
(bootloader grub-efi-bootloader)
(target "/boot/efi")))
;(keyboard-layout keyboard-layout)))
;; Add a stub entry for filesystem.
(file-systems (cons*
(file-system
(mount-point "/tmp")
(device "none")
(type "tmpfs")
(check? #f))
%base-file-systems))
(users
(cons
(user-account
(name "cylon2p0")
(group "users")
(home-directory "/home/cylon2p0")
(supplementary-groups
'("wheel" ;; sudo
"netdev" ;; network devices
"kvm"
"tty"
"input"
"adbusers" ;; Android tools
"docker"
"realtime" ;; Enable realtime scheduling
"lp" ;; control bluetooth devices
"audio" ;; control audio devices
"video"))) ;; control video devices
%base-user-accounts))
;; Add the 'realtime' group
(groups
(cons
(user-group
(system? #t)
(name "realtime"))
%base-groups))
;; Install bare-minimum system packages
(packages
(append
(list
git
tig
openconnect
wireguard-tools
librealsense
ntfs-3g
exfat-utils
fuse-exfat
vim
tmux
emacs
alacritty
bluez
bluez-alsa
pulseaudio
gnupg
password-store
pass-otp
tlp
xf86-input-libinput
i3-gaps ;; i3 desktop
i3lock
i3lock-blur
i3status
light
dmenu
ungoogled-chromium
redshift
libreoffice
mpv
zathura
nss-certs ;; for HTTPS access
gvfs) ;; for user mounts
%base-packages))
;; Use the "desktop" services, which include the X11 log-in service,
;; networking with NetworkManager, and more
(services
(cons*
(service slim-service-type
(slim-configuration
(xorg-configuration
(xorg-configuration
;(keyboard-layout keyboard-layout)
(extra-config
(list %xorg-libinput-config
%xorg-enable-dri3
%xorg-intel-screen-tearing-fix))))))
(screen-locker-service i3lock "i3lock")
(service nftables-service-type
(nftables-configuration
(ruleset
(local-file (string-append %endgame-directory "/conf/nftables.conf")))))
; (service upower-service-type
; (upower-configuration
; (use-percentage-for-policy? #t)
; (percentage-low 25)
; (percentage-critical 10)
; (percentage-action 5)
; ;;(ignore-lid? #:t)
; (watts-up-pro? #:f)
; (poll-batteries? #:t)
; (critical-power-action 'hybrid-sleep)))
;(service tlp-service-type
; (tlp-configuration
; (cpu-boost-on-ac? #t)
; (wifi-pwr-on-bat? #t)))
(pam-limits-service
(list
(pam-limits-entry "@realtime" 'both 'rtprio 99)
(pam-limits-entry "@realtime" 'both 'memlock 'unlimited)))
(extra-special-file "/usr/bin/env"
(file-append coreutils "/bin/env"))
;(service thermald-service-type)
(simple-service 'os-release etc-service-type
`(("os-release" ,%os-release-file)))
(simple-service 'cron-jobs
mcron-service-type
(list %garbage-collector-job-system))
;; Add udev rules for MTP devices so that non-root users can access
;; them.
(simple-service 'mtp udev-service-type (list libmtp))
;; Add udev rules for scanners.
(service sane-service-type)
;; Add network-manager applet
(simple-service 'network-manager-applet
profile-service-type
(list network-manager-applet))
(service dnsmasq-service-type
(dnsmasq-configuration
(no-resolv? #t)
(servers '("193.17.47.1" "185.43.135.1"))))
(service docker-service-type)
(service pcscd-service-type)
(service earlyoom-service-type
(earlyoom-configuration
(prefer-regexp "chromium")))
(service libvirt-service-type
(libvirt-configuration
(unix-sock-group "libvirt")
(tls-port "16555")))
(service qemu-binfmt-service-type
(qemu-binfmt-configuration
(platforms (lookup-qemu-platforms "arm" "aarch64"))))
(service cups-service-type
(cups-configuration
(web-interface? #t)
(extensions
(list cups-filters))))
;; make guix system autoupgrade itself once a week!
(service unattended-upgrade-service-type
(unattended-upgrade-configuration
(schedule "30 01 * * 0")
(system-expiration (* 3 30 24 3600))))
(service nix-service-type)
(udev-rules-service 'android android-udev-rules #:groups '("adbusers"))
(bluetooth-service #:auto-enable? #t)
(remove (lambda (service)
(eq? (service-kind service) gdm-service-type))
%my-desktop-services)))
;; Allow resolution of '.local' host names with mDNS
(name-service-switch %mdns-host-lookup-nss)))
;; NOTE: Private key must be manually place into the location
(define (wire-vpn public-key ipaddr)
(service wireguard-service-type
(wireguard-configuration
(peers
(list
(wireguard-peer
(name "dungeon")
(endpoint "37.205.12.244:60990")
(public-key public-key)
(allowed-ips '("10.100.0.0/24")))))
(addresses ipaddr)
(private-key "/etc/wireguard/wg0-priv.key"))))