modules/ryan-config/base-system.scm

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