modules/ryan-config/base-system.scm

438237dbff8b535bfcf4cac7625c9b085e4b6c53 · 10.9 KB · 234 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 "dconf"
145 "wireplumber"
146 "wireshark"
147 "zsh"))
148 (list my-ca-certs swaylock-effects-new waybar-new xdg-desktop-portal-hyprland)
149 %my-base-packages ))
150
151 ;; Below is the list of system services. To search for available
152 ;; services, run 'guix system search KEYWORD' in a terminal.
153 (services
154 (append (list
155
156 ;; To configure OpenSSH, pass an 'openssh-configuration'
157 ;; record as a second argument to 'service' below.
158 (service openssh-service-type)
159 (service pcscd-service-type)
160 (service cups-service-type
161 (cups-configuration
162 (web-interface? #t)))
163 ;; Avahi is only present for CUPS to support "automagic" printing
164 (service avahi-service-type
165 (avahi-configuration
166 (publish? #f) ;; do not advertise this machine
167 (publish-workstation? #f))) ;; do not advertise, I want this to be as silent as possible
168 (service docker-service-type)
169 (service nix-service-type)
170 (service libvirt-service-type
171 (libvirt-configuration
172 (unix-sock-group "libvirt")))
173 (service virtlog-service-type)
174 (service bluetooth-service-type)
175 (udev-rules-service 'fido2 libfido2 #:groups '("plugdev")))
176
177 ;; This is the default list of services we
178 ;; are appending to.
179 (modify-services %desktop-services
180 (guix-service-type config =>
181 (guix-configuration
182 (inherit config)
183 (substitute-urls
184 (append (list "https://substitutes.nonguix.org")
185 %default-substitute-urls))
186 (authorized-keys
187 (cons* (plain-file "non-guix.pub"
188 "(public-key
189 (ecc
190 (curve Ed25519)
191 (q #C1FD53E5D4CE971933EC50C9F307AE2171A2D3B52C804642A7A35F84F3A4EA98#)
192 )
193 )" ) %default-authorized-guix-keys))))
194 (udev-service-type config =>
195 (udev-configuration
196 (inherit config)
197 (rules (cons %backlight-udev-rule
198 (udev-configuration-rules config)))))
199 (delete pulseaudio-service-type)
200 (delete gdm-service-type)
201 (delete avahi-service-type)
202 ;(delete xorg-server-service-type)
203 (delete alsa-service-type) )))
204 (name-service-switch %mdns-host-lookup-nss) ;; Enable .local lookup
205 (setuid-programs
206 (append (list (file-like->setuid-program
207 (file-append
208 ;(specification->package "swaylock-effects")
209 swaylock-effects-new
210 "/bin/swaylock"))
211 (file-like->setuid-program
212 (file-append
213 (specification->package "wireshark")
214 "/bin/dumpcap"))
215 (file-like->setuid-program
216 (file-append
217 (specification->package "spice-gtk")
218 "/libexec/spice-client-glib-usb-acl-helper"))
219 (file-like->setuid-program
220 (file-append
221 (specification->package "opendoas")
222 "/bin/doas")))
223 (delete sudo %setuid-programs)))
224 (file-systems (cons*
225 (file-system
226 (mount-point "/tmp")
227 (device "none")
228 (type "tmpfs")
229 (check? #f))
230 %base-file-systems))
231 (bootloader (bootloader-configuration
232 (bootloader grub-efi-bootloader)
233 (targets (list "/boot/efi"))
234 (keyboard-layout keyboard-layout)))))