modules/ryan-config/base-system.scm

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