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