modules/ryan-config/base-system.scm
1b531a384961505e98d3475694dd5767c8d73714
· 11.2 KB · 239 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 | "alacritty" |
| 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 waybar-new xdg-desktop-portal-hyprland 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 | (delete pulseaudio-service-type) |
| 205 | (delete gdm-service-type) |
| 206 | (delete avahi-service-type) |
| 207 | ;(delete xorg-server-service-type) |
| 208 | (delete alsa-service-type) ))) |
| 209 | (name-service-switch %mdns-host-lookup-nss) ;; Enable .local lookup |
| 210 | (setuid-programs |
| 211 | (append (list (file-like->setuid-program |
| 212 | (file-append |
| 213 | ;(specification->package "swaylock-effects") |
| 214 | swaylock-effects-new |
| 215 | "/bin/swaylock")) |
| 216 | (file-like->setuid-program |
| 217 | (file-append |
| 218 | (specification->package "wireshark") |
| 219 | "/bin/dumpcap")) |
| 220 | (file-like->setuid-program |
| 221 | (file-append |
| 222 | (specification->package "spice-gtk") |
| 223 | "/libexec/spice-client-glib-usb-acl-helper")) |
| 224 | (file-like->setuid-program |
| 225 | (file-append |
| 226 | (specification->package "opendoas") |
| 227 | "/bin/doas"))) |
| 228 | (delete sudo %setuid-programs))) |
| 229 | (file-systems (cons* |
| 230 | (file-system |
| 231 | (mount-point "/tmp") |
| 232 | (device "none") |
| 233 | (type "tmpfs") |
| 234 | (check? #f)) |
| 235 | %base-file-systems)) |
| 236 | (bootloader (bootloader-configuration |
| 237 | (bootloader grub-efi-bootloader) |
| 238 | (targets (list "/boot/efi")) |
| 239 | (keyboard-layout keyboard-layout))))) |