aboutsummaryrefslogtreecommitdiff
path: root/tw/system.scm
diff options
context:
space:
mode:
authorTimo Wilken2024-07-11 17:11:25 +0200
committerTimo Wilken2024-07-11 17:11:25 +0200
commite6f26581bf22e266c5056eddfb264eca2efb6ef4 (patch)
tree08c436f4b5d4fe66bbf9b6a67bb1020568737e93 /tw/system.scm
parentc2c6421d3f8db9920fe50f07eff226641586f87a (diff)
Wayland-based desktop support
Add a separate home service to configure a Wayland-based desktop instead of an X11 one. Screensharing in Zoom doesn't work unfortunately, but it worked (at least for a while) through OBS. Waybar might need some work to bring it in line with the previous polybar configuration, especially in terms of aesthetics.
Diffstat (limited to 'tw/system.scm')
-rw-r--r--tw/system.scm119
1 files changed, 80 insertions, 39 deletions
diff --git a/tw/system.scm b/tw/system.scm
index 7e7f8aa8..67dea549 100644
--- a/tw/system.scm
+++ b/tw/system.scm
@@ -1,12 +1,15 @@
(define-module (tw system)
#:use-module (ice-9 string-fun)
+ #:use-module (srfi srfi-26)
#:use-module (gnu)
#:use-module (gnu services)
#:use-module (gnu system)
#:use-module (gnu system keyboard)
#:use-module (guix gexp)
#:use-module (tw channels)
+ #:use-module (tw packages catppuccin)
#:use-module (tw packages scanner)
+ #:use-module (tw services desktop)
#:use-module (tw services wireguard))
(use-package-modules acl admin android avahi backup certs cups curl disk
@@ -32,7 +35,7 @@
(comment "Timo Wilken")
(group "users")
(home-directory "/home/timo")
- (supplementary-groups '("wheel" "netdev" "audio" "video"))
+ (supplementary-groups '("wheel" "input" "netdev" "audio" "video"))
(shell (file-append zsh "/bin/zsh")))
%base-user-accounts))
@@ -90,12 +93,15 @@
(port (format #f "~a:~a" ip port))
(else ip))))
+(define system-base-packages-service
+ (simple-service 'tw-base-packages profile-service-type
+ (list acl acpi age btrfs-progs cpupower curl efibootmgr exfat-utils git
+ glibc-locales hddtemp htop lshw lsof man-db man-pages man-pages-posix
+ mlocate moreutils nss-mdns python restic rsync strace vim wireguard-tools)))
+
(define-public (server-base-services host-name)
(cons*
- (simple-service 'tw-base-packages profile-service-type
- (list acl acpi age btrfs-progs cpupower curl efibootmgr exfat-utils git
- glibc-locales hddtemp htop lshw lsof man-db man-pages man-pages-posix
- mlocate moreutils nss-mdns python restic rsync strace vim wireguard-tools))
+ system-base-packages-service
(tw-openssh-service host-name)
@@ -197,6 +203,7 @@ ACTION!=\"remove\", SUBSYSTEM==\"leds\", GROUP=\"video\", MODE=\"0664\"
(define* (enduser-system-services
#:key
host-name cores wireless-interface backlight-device
+ (wayland? #f)
(work-system? #f)
(xorg-extra-modules '())
(xorg-drivers '()))
@@ -209,18 +216,17 @@ ACTION!=\"remove\", SUBSYSTEM==\"leds\", GROUP=\"video\", MODE=\"0664\"
(list? xorg-drivers))
(error "Invalid argument type"))
- (define xorg-config
- (xorg-configuration
- (keyboard-layout %british-keyboard)
- (extra-config (list touchpad-xorg-config))
- (modules (append xorg-extra-modules %default-xorg-modules))
- (drivers xorg-drivers)))
-
(cons*
+ system-base-packages-service
(simple-service 'tw-enduser-packages profile-service-type
(list cups docker mit-krb5 pulseaudio dosfstools mtools ntfs-3g
;; Install window manager here so gdm can see its xsession file.
- i3-wm))
+ (if wayland? swayfx i3-wm)))
+
+ (simple-service 'screen-locker pam-root-service-type
+ (list (pam-service
+ (name (if wayland? "swaylock" "i3lock"))
+ (auth (list (pam-entry (control "include") (module "login")))))))
(service docker-service-type)
@@ -240,14 +246,6 @@ ACTION!=\"remove\", SUBSYSTEM==\"leds\", GROUP=\"video\", MODE=\"0664\"
(service earlyoom-service-type
(earlyoom-configuration)) ; TODO: configure at least `avoid-regexp'
- (set-xorg-configuration xorg-config)
-
- ;; Install i3lock as a setuid binary, so it can talk to PAM.
- (service screen-locker-service-type
- (screen-locker-configuration
- (name "i3lock")
- (program (file-append i3lock "/bin/i3lock"))))
-
;; Allow anyone in the "video" group to set the display's brightness.
;; Run `udevadm info -q all /sys/class/backlight/*' to see properties.
(udev-rules-service 'backlight backlight-udev-rules #:groups '("video"))
@@ -360,30 +358,73 @@ ACTION!=\"remove\", SUBSYSTEM==\"leds\", GROUP=\"video\", MODE=\"0664\"
(string-append #$(file-append util-linux "/sbin/fstrim")
" --fstab --verbose"))))
- (modify-services (append %system-channel-services %desktop-services)
- (guix-service-type
- config =>
- (guix-configuration
- (inherit config)
- (channels %system-channels)))
+ (if wayland?
+ (wayland-enduser-base-services)
+ (x11-enduser-base-services work-system? xorg-extra-modules xorg-drivers))))
- ;; Let sane find the airscan backend. ipp-usb needs to be running separately.
- (sane-service-type _ => sane-backends/airscan)
+(define enduser-base-services
+ (modify-services (append %system-channel-services %desktop-services)
+ (guix-service-type
+ config =>
+ (guix-configuration
+ (inherit config)
+ (channels %system-channels)))
+ ;; Let sane find the airscan backend. ipp-usb needs to be running separately.
+ (sane-service-type _ => sane-backends/airscan)
+
+ (geoclue-service-type
+ config =>
+ (geoclue-configuration
+ (inherit config)
+ (applications
+ (cons* (geoclue-application "redshift" #:system? #f)
+ %standard-geoclue-applications))))
+
+ (login-service-type config => (tw-login-configuration config))))
+
+(define (x11-enduser-base-services work-system? xorg-extra-modules xorg-drivers)
+ (define xorg-config
+ (xorg-configuration
+ (keyboard-layout %british-keyboard)
+ (extra-config (list touchpad-xorg-config))
+ (modules (append xorg-extra-modules %default-xorg-modules))
+ (drivers xorg-drivers)))
+
+ (cons*
+ (set-xorg-configuration xorg-config)
+ (modify-services enduser-base-services
(gdm-service-type
config =>
(gdm-configuration
(inherit config)
(auto-login? #f)
(default-user (if work-system? "twilken" "timo"))
- (xorg-configuration xorg-config)))
-
- (geoclue-service-type
- config =>
- (geoclue-configuration
- (inherit config)
- (applications
- (cons* (geoclue-application "redshift" #:system? #f)
- %standard-geoclue-applications))))
+ (xorg-configuration xorg-config))))))
- (login-service-type config => (tw-login-configuration config)))))
+(define (wayland-enduser-base-services)
+ (cons*
+ (service greetd-service-type
+ (greetd-configuration
+ (terminals
+ (list (greetd-terminal-configuration
+ (terminal-switch #t)
+ (default-session-command
+ (greetd-wlgreet-sway-session
+ (sway-configuration %sway-common-configuration)
+ (wlgreet-session
+ (greetd-wlgreet-session
+ (command (file-append swayfx "/bin/sway"))
+ (scale 1) ; TODO
+ ;; Catppuccin colours.
+ ;; Note: if these are Guile rationals, they will be written
+ ;; to wlgreet.toml in fractional form and wlgreet will crash.
+ (background '(0.12 0.12 0.18 1.0)) ; base
+ (headline '(0.80 0.84 0.95 1.0)) ; text
+ (prompt '(0.80 0.84 0.95 1.0)) ; text
+ (prompt-error '(0.97 0.88 0.68 1.0)) ; yellow
+ (border '(0.35 0.36 0.44 1.0))))))))))) ; sway window border
+ (modify-services enduser-base-services
+ ;; Not needed for pure Wayland, but Zoom uses xwayland.
+ ;; (delete x11-socket-directory-service-type)
+ (delete gdm-service-type))))