modules/ryan-config/base-system.scm

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