modules/ryan-config/base-system.scm

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