modules/ryan-config/base-system.scm

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