modules/ryan-config/base-system.scm

f1bc773106aae04b7f622e72cbfd1650c24b1ed7 · 14.4 KB · 293 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 (rosenthal packages wm)
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 (gnu 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 (simple-service 'hyprlock-pam pam-root-service-type
197 (list
198 (pam-service
199 (name "hyprlock")
200 (auth
201 (list
202 (pam-entry (control "include")
203 (module "login")))))))
204 (service libvirt-service-type
205 (libvirt-configuration
206 (libvirt libvirt-ovmf)
207 (unix-sock-group "libvirt")))
208 (service virtlog-service-type)
209 ;(service screen-locker-service-type
210 ; (screen-locker-configuration
211 ; (name "hyprlock")
212 ; (program (file-append swaylock "/bin/swaylock"))
213 ; (using-pam? #t)))
214 (simple-service 'spice-polkit polkit-service-type (list spice-gtk))
215 (simple-service 'hwdb-creation etc-service-type (list `("udev-here-oneoneone" ,(plain-file "issue" "test\n"))))
216 (service bluetooth-service-type
217 (bluetooth-configuration
218 (bluez bluez-ryan)
219 (experimental #t)
220 (fast-connectable? #t)))
221 (udev-rules-service 'fido2 libfido2 #:groups '("plugdev")))
222
223 ;; This is the default list of services we
224 ;; are appending to.
225 (modify-services %desktop-services
226 (guix-service-type config =>
227 (guix-configuration
228 (inherit config)
229 (substitute-urls
230 (append (list "https://substitutes.nonguix.org")
231 %default-substitute-urls))
232 (authorized-keys
233 (cons* (plain-file "non-guix.pub"
234 "(public-key
235 (ecc
236 (curve Ed25519)
237 (q #C1FD53E5D4CE971933EC50C9F307AE2171A2D3B52C804642A7A35F84F3A4EA98#)
238 )
239 )" ) %default-authorized-guix-keys))))
240 (udev-service-type config =>
241 (udev-configuration
242 (inherit config)
243 (rules (cons* %backlight-udev-rule
244 %flipper-udev-rule
245 (udev-configuration-rules config)))))
246 (elogind-service-type config =>
247 (elogind-configuration
248 (inherit config)
249 (handle-power-key `ignore)
250 (handle-suspend-key `ignore)
251 (handle-lid-switch `ignore)
252 (kill-user-processes? #t)))
253 (network-manager-service-type config =>
254 (network-manager-configuration
255 (inherit config)
256 (vpn-plugins
257 (list network-manager-openconnect))))
258 (delete pulseaudio-service-type)
259 (delete gdm-service-type)
260 (delete avahi-service-type)
261 ;(delete xorg-server-service-type)
262 (delete alsa-service-type) )))
263 (name-service-switch %mdns-host-lookup-nss) ;; Enable .local lookup
264 (setuid-programs
265 (append (list ;(file-like->setuid-program
266 ;(file-append
267 ;(specification->package "swaylock-effects")
268 ; swaylock-effects-new
269 ; "/bin/swaylock"))
270 (file-like->setuid-program
271 (file-append
272 (specification->package "wireshark")
273 "/bin/dumpcap"))
274 (file-like->setuid-program
275 (file-append
276 (specification->package "spice-gtk")
277 "/libexec/spice-client-glib-usb-acl-helper"))
278 (file-like->setuid-program
279 (file-append
280 (specification->package "opendoas")
281 "/bin/doas")))
282 (delete sudo %setuid-programs)))
283 (file-systems (cons*
284 (file-system
285 (mount-point "/tmp")
286 (device "none")
287 (type "tmpfs")
288 (check? #f))
289 %base-file-systems))
290 (bootloader (bootloader-configuration
291 (bootloader grub-efi-bootloader)
292 (targets (list "/boot/efi"))
293 (keyboard-layout keyboard-layout)))))