modules/ryan-config/base-system.scm

f4b1d571ae0d6527fd933baadc64e9d67cd56456 · 13.4 KB · 276 lines raw

1 (define-module (ryan-config base-system)
2 #:use-module (gnu)
3 #:use-module (nongnu packages linux)
4 #:use-module (gnu system setuid)
5 #:use-module (gnu packages admin)
6 #:use-module (gnu packages avahi)
7 #:use-module (gnu packages wm)
8 #:use-module (guix packages)
9 #:use-module (gnu packages shells)
10 #:use-module (guix build-system trivial)
11 #:use-module (guix licenses)
12 #:use-module (gnu packages tls)
13 #:use-module (gnu packages spice)
14 #:use-module (srfi srfi-1)
15 #:use-module (ryan-packages freedesktop)
16 ;#:use-module (ryan-packages hyprland)
17 #:use-module (ryan-packages wm)
18 #:use-module (ryan-packages virtualization)
19 #:use-module (ryan-packages linux)
20 #:use-module (ryan-packages networking)
21 #:use-module (rosenthal packages wm)
22 #:use-module (rosenthal services networking)
23 #:use-module (gnu packages security-token)
24 #:use-module (gnu services security-token)
25 #:use-module (gnu services cups)
26 #:use-module (gnu services desktop)
27 #:use-module (gnu services networking)
28 #:use-module (gnu services xorg)
29 #:use-module (gnu services ssh)
30 #:use-module (gnu services nix)
31 #:use-module (gnu services sound)
32 #:use-module (gnu services docker)
33 #:use-module (gnu services avahi)
34 #:use-module (gnu services dbus)
35 #:use-module (gnu services virtualization))
36
37 ; Define package that installs my root ca public keys
38 (define my-ca-certs
39 (package
40 (name "my-ca-certs")
41 (version "1")
42 (source (local-file "./CACerts"
43 #:recursive? #t))
44 (build-system trivial-build-system)
45 (license mpl2.0)
46 (home-page "https://rschanz.org")
47 (arguments
48 `(#:modules
49 ((guix build utils))
50 #:builder
51 (begin
52 (use-modules (guix build utils)
53 (srfi srfi-1)
54 (srfi srfi-26)
55 (ice-9 ftw))
56 (let* ((ca-certificates (assoc-ref %build-inputs "source"))
57 (crt-suffix ".crt")
58 (is-certificate? (cut string-suffix? crt-suffix <>))
59 (certificates (filter is-certificate?
60 (scandir ca-certificates)))
61 (out (assoc-ref %outputs "out"))
62 (certificate-directory (string-append out "/etc/ssl/certs"))
63 (openssl (string-append (assoc-ref %build-inputs "openssl") "/bin/openssl")))
64 (mkdir-p certificate-directory)
65 (for-each
66 (lambda (cert)
67 (invoke
68 openssl "x509"
69 "-in" (string-append ca-certificates "/" cert)
70 "-outform" "PEM"
71 "-out" (string-append certificate-directory "/" cert ".pem")))
72 certificates)
73 #t))))
74 (native-inputs
75 (list openssl))
76 (synopsis "My CA Certs")
77 (description synopsis)))
78
79 ; Re-define the base packages to remove sudo
80 (define %my-base-packages
81 (remove (lambda (package)
82 (member (package-name package)
83 (list "sudo" "nano")))
84 %base-packages ))
85
86 (define %backlight-udev-rule
87 (udev-rule
88 "90-backlight.rules"
89 (string-append "ACTION==\"add\", SUBSYSTEM==\"backlight\", "
90 "RUN+=\"/run/current-system/profile/bin/chgrp video /sys/class/backlight/%k/brightness\""
91 "\n"
92 "ACTION==\"add\", SUBSYSTEM==\"backlight\", "
93 "RUN+=\"/run/current-system/profile/bin/chmod g+w /sys/class/backlight/%k/brightness\"")))
94
95 (define %flipper-udev-rule
96 (udev-rule
97 "42-flipperzero.rules"
98 (string-append "SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"0483\", ATTRS{idProduct}==\"5740\", ATTRS{manufacturer}==\"Flipper Devices Inc.\", TAG+=\"uaccess\""
99 "\n"
100 "SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"0483\", ATTRS{idProduct}==\"df11\", ATTRS{manufacturer}==\"STMicroelectronics\", TAG+=\"uaccess\""
101 "\n"
102 "SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"303a\", ATTRS{idProduct}==\"40??\", ATTRS{manufacturer}==\"Flipper Devices Inc.\", TAG+=\"uaccess\"")))
103
104 (define-public base-operating-system
105 (operating-system
106 (kernel linux)
107 (firmware (list linux-firmware))
108 (locale "en_US.utf8")
109 (timezone "America/New_York")
110 (keyboard-layout (keyboard-layout "us"))
111 (host-name "ThisWillChange")
112
113 ;; The list of user accounts ('root' is implicit).
114 (users (cons* (user-account
115 (name "ryan")
116 (comment "Ryan")
117 (group "users")
118 (shell (file-append fish "/bin/fish"))
119 (home-directory "/home/ryan")
120 (supplementary-groups '("wheel" "netdev" "audio" "video" "lp" "plugdev" "docker" "libvirt" "kvm" "dialout")))
121 %base-user-accounts))
122
123 ;; Packages installed system-wide. Users can also install packages
124 ;; under their own account: use 'guix search KEYWORD' to search
125 ;; for packages and 'guix install PACKAGE' to install a package.
126 (packages (append (map specification->package (list "sway"
127 ;"hyprland"
128 "swaybg"
129 ;"swayidle"
130 ;"swaylock-effects"
131 "fuzzel"
132 "foot"
133 "pinentry-qt"
134 "adwaita-icon-theme"
135 "hicolor-icon-theme"
136 "git"
137 "waybar-experimental"
138 "gnupg"
139 "light"
140 "avahi"
141 "mako"
142 "grim"
143 "grimblast"
144 "slurp"
145 "wl-clipboard"
146 ;"bluez"
147 ;"blueman"
148 "ldacbt"
149 "libfreeaptx"
150 "libfdk"
151 "opendoas"
152 ;"xdg-desktop-portal-wlr"
153 ;"xdg-desktop-portal"
154 ;"xdg-desktop-portal-gtk"
155 "v4l2loopback-linux-module"
156 "pipewire"
157 "docker"
158 ;"libvirt" ;New version inherited from service
159 ;"virt-manager"
160 "dconf"
161 "wireplumber"
162 "wireshark"
163 "webkitgtk-with-libsoup2" ; Needed for Go wails development
164 "zsh"))
165 (list my-ca-certs virt-manager-ovmf bluez-ryan blueman-ryan swayidle-new)
166 %my-base-packages ))
167
168 ;; Below is the list of system services. To search for available
169 ;; services, run 'guix system search KEYWORD' in a terminal.
170 (services
171 (append (list
172
173 ;; To configure OpenSSH, pass an 'openssh-configuration'
174 ;; record as a second argument to 'service' below.
175 (service openssh-service-type)
176 (service pcscd-service-type)
177 (service cups-service-type
178 (cups-configuration
179 (web-interface? #t)))
180 ;; Avahi is only present for CUPS to support "automagic" printing
181 (service avahi-service-type
182 (avahi-configuration
183 (publish? #f) ;; do not advertise this machine
184 (publish-workstation? #f))) ;; do not advertise, I want this to be as silent as possible
185 (service docker-service-type)
186 ; Tailscale daemon from rosenthal
187 (service tailscale-service-type
188 (tailscale-configuration
189 (socket "/var/run/tailscale/tailscaled.sock")))
190 (service containerd-service-type)
191 (service nix-service-type)
192 (service libvirt-service-type
193 (libvirt-configuration
194 (libvirt libvirt-ovmf)
195 (unix-sock-group "libvirt")))
196 (service virtlog-service-type)
197 (service screen-locker-service-type
198 (screen-locker-configuration
199 (name "hyprlock")
200 (program (file-append swaylock "/bin/swaylock"))
201 (using-pam? #t)))
202 (simple-service 'spice-polkit polkit-service-type (list spice-gtk))
203 (simple-service 'hwdb-creation etc-service-type (list `("udev-here-oneoneone" ,(plain-file "issue" "test\n"))))
204 (service bluetooth-service-type
205 (bluetooth-configuration
206 (bluez bluez-ryan)
207 (experimental #t)
208 (fast-connectable? #t)))
209 (udev-rules-service 'fido2 libfido2 #:groups '("plugdev")))
210
211 ;; This is the default list of services we
212 ;; are appending to.
213 (modify-services %desktop-services
214 (guix-service-type config =>
215 (guix-configuration
216 (inherit config)
217 (substitute-urls
218 (append (list "https://substitutes.nonguix.org")
219 %default-substitute-urls))
220 (authorized-keys
221 (cons* (plain-file "non-guix.pub"
222 "(public-key
223 (ecc
224 (curve Ed25519)
225 (q #C1FD53E5D4CE971933EC50C9F307AE2171A2D3B52C804642A7A35F84F3A4EA98#)
226 )
227 )" ) %default-authorized-guix-keys))))
228 (udev-service-type config =>
229 (udev-configuration
230 (inherit config)
231 (rules (cons* %backlight-udev-rule
232 %flipper-udev-rule
233 (udev-configuration-rules config)))))
234 (elogind-service-type config =>
235 (elogind-configuration
236 (inherit config)
237 (handle-power-key `ignore)
238 (handle-suspend-key `ignore)
239 (handle-lid-switch `ignore)
240 (kill-user-processes? #t)))
241 (delete pulseaudio-service-type)
242 (delete gdm-service-type)
243 (delete avahi-service-type)
244 ;(delete xorg-server-service-type)
245 (delete alsa-service-type) )))
246 (name-service-switch %mdns-host-lookup-nss) ;; Enable .local lookup
247 (setuid-programs
248 (append (list ;(file-like->setuid-program
249 ;(file-append
250 ;(specification->package "swaylock-effects")
251 ; swaylock-effects-new
252 ; "/bin/swaylock"))
253 (file-like->setuid-program
254 (file-append
255 (specification->package "wireshark")
256 "/bin/dumpcap"))
257 (file-like->setuid-program
258 (file-append
259 (specification->package "spice-gtk")
260 "/libexec/spice-client-glib-usb-acl-helper"))
261 (file-like->setuid-program
262 (file-append
263 (specification->package "opendoas")
264 "/bin/doas")))
265 (delete sudo %setuid-programs)))
266 (file-systems (cons*
267 (file-system
268 (mount-point "/tmp")
269 (device "none")
270 (type "tmpfs")
271 (check? #f))
272 %base-file-systems))
273 (bootloader (bootloader-configuration
274 (bootloader grub-efi-bootloader)
275 (targets (list "/boot/efi"))
276 (keyboard-layout keyboard-layout)))))