diff options
author | Timo Wilken | 2024-06-05 09:11:07 +0200 |
---|---|---|
committer | Timo Wilken | 2024-06-05 10:09:32 +0200 |
commit | 947800dda8e1a6f72c963a1f12c8e06d9c5e68f9 (patch) | |
tree | 08f6429a0cd89b4ae27ba9210f705ddd72a36fb4 | |
parent | e749c97ffb35eba54d94d6069613475971d69c90 (diff) |
Extract gaming-specific config into its own service
-rw-r--r-- | tw/home/btl.scm | 3 | ||||
-rw-r--r-- | tw/home/lap.scm | 5 | ||||
-rw-r--r-- | tw/services/desktop.scm | 112 |
3 files changed, 71 insertions, 49 deletions
diff --git a/tw/home/btl.scm b/tw/home/btl.scm index cf6e8fd4..9449b1c3 100644 --- a/tw/home/btl.scm +++ b/tw/home/btl.scm @@ -50,13 +50,14 @@ (service home-desktop-service-type (home-desktop-configuration - (gaming? #t) (bluetooth? #t) (monitors (list (home-monitor-configuration (name "DisplayPort-2") (xrandr-options '("--mode" "2560x1440" "--rate" "143.86"))))))) + (service home-gaming-service-type) + (service home-full-dev-env-service-type) (service home-pim-service-type) diff --git a/tw/home/lap.scm b/tw/home/lap.scm index 4b18b5c1..eb28b7cf 100644 --- a/tw/home/lap.scm +++ b/tw/home/lap.scm @@ -97,7 +97,6 @@ (service home-desktop-service-type (home-desktop-configuration - (gaming? #t) (nvidia-driver? #t) (bluetooth? #t) (battery-name "BAT0") @@ -107,6 +106,10 @@ (name "eDP-1-1") (xrandr-options '("--auto"))))))) + (service home-gaming-service-type + (home-gaming-configuration + (nvidia-driver? #t))) + (service home-full-dev-env-service-type) ;; On my private machine, I want to use my private PGP key normally, and diff --git a/tw/services/desktop.scm b/tw/services/desktop.scm index 1aa2bb2d..9ec06bce 100644 --- a/tw/services/desktop.scm +++ b/tw/services/desktop.scm @@ -71,6 +71,8 @@ #:export (home-desktop-configuration home-monitor-configuration home-desktop-service-type + home-gaming-configuration + home-gaming-service-type home-pim-configuration home-pim-service-type)) @@ -91,7 +93,6 @@ configure this monitor.")) (and (list? thing) (every home-monitor-configuration? thing))) (define-configuration/no-serialization home-desktop-configuration - (gaming? (boolean #f) "Install games and other packages useful for gaming?") (nvidia-driver? (boolean #f) "Adapt the X11 desktop for the proprietary NVIDIA driver?") (desktop-background @@ -146,7 +147,7 @@ to list zones and their types.") (define (home-packages config) "Install packages I use frequently." - (cons* + (list ;; CLI tools bsd-games powertop (list git "send-email") pdsh qrencode texlive-scheme-small texlive-latexmk @@ -186,15 +187,8 @@ to list zones and their types.") ;; Theming papirus-icon-theme catppuccin-gtk-theme catppuccin-mocha-dark-cursors ;; Games (larger games installed in ~/.guix-profile to avoid frequent huge downloads). - szio-solitaire prismlauncher ;; 0ad flightgear freeciv simutrans/pak128 warzone2100 widelands pioneer - - (match-record config <home-desktop-configuration> (gaming? nvidia-driver?) - (if (not gaming?) '() - (if nvidia-driver? - ;; nvidia-system-monitor: Qt; installs "qnvsm" binary, but no .desktop file - (list steam-nvidia nvidia-system-monitor) - (list steam radeontop)))))) + szio-solitaire prismlauncher)) (define xfce4-screenshooter.conf (mixed-text-file "xfce4-screenshooter.conf" "\ @@ -244,32 +238,7 @@ show_border=1 ("rofi/themes/catppuccin.rasi" ,catppuccin-rofi) ("xfce4/xfce4-screenshooter" ,xfce4-screenshooter.conf) ("zathura/zathurarc" ,(local-file "files/zathurarc")) - ("zathura/catppuccin" ,catppuccin-zathura) - - ,@(match-record config <home-desktop-configuration> (gaming?) - (if gaming? - `(("guix-gaming-channels/games.scm" - ,(scheme-file "guix-gaming-credentials.scm" - #~(begin - (use-modules (ice-9 rdelim) (ice-9 popen)) - (define gog-credentials - (let* ((pass (open-pipe* OPEN_READ "pass" "show" "software/games/gog")) - (password (read-line pass)) - (username - (let loop ((line (read-line pass))) - (cond - ((eof-object? line) - (error "Could not find username in pass output")) - ((string-prefix? "username: " line) - (string-trim - (substring line (string-length "username:")))) - (else (loop (read-line pass))))))) - (close-pipe pass) - `((email ,username) - (password ,password)))) - (make-gaming-config - `((gog ,gog-credentials))))))) - '())))) + ("zathura/catppuccin" ,catppuccin-zathura))) (define (home-files config) "Extra configuration files and binaries that don't follow the XDG spec." @@ -311,17 +280,6 @@ show_border=1 (define (home-environment config) `(("TERMINAL" . "kitty") ("QT_X11_NO_MITSHM" . "1") ; fixes a Steam issue: https://gitlab.com/nonguix/nonguix/-/issues/267 - ("GUIX_SANDBOX_EXTRA_SHARES" . ; mount savegame locations inside Steam container - ,(string-join - '("$HOME/savegames/banished=$HOME/.local/share/Steam/steamapps/compatdata/242920/pfx/drive_c/users/steamuser/Documents/Banished/Save" - "$HOME/savegames/planetbase=$HOME/.local/share/Steam/steamapps/compatdata/403190/pfx/drive_c/users/steamuser/Documents/Planetbase" - "$HOME/savegames/cities-skylines=$HOME/.local/share/Colossal Order/Cities_Skylines/Saves" - "$HOME/savegames/surviving-mars=$HOME/.local/share/Surviving Mars/76561198130982912" - "$HOME/savegames/colony-survival=$HOME/.local/share/Steam/steamapps/common/Colony Survival/gamedata/savegames" - "$HOME/savegames/portal=$HOME/.local/share/Steam/steamapps/common/Portal/portal/save" - "$HOME/savegames/spacechem=$HOME/.local/share/Zachtronics Industries/SpaceChem/save" - "$HOME/savegames/tis-100=$HOME/.local/share/TIS-100/76561198130982912") - ":")) ;; Smooth trackpad scrolling in Firefox/Icecat. ;; https://wiki.archlinux.org/index.php/Firefox/Tweaks#Pixel-perfect_trackpad_scrolling ("MOZ_USE_XINPUT2" . "1") @@ -446,6 +404,66 @@ show_border=1 (service-extension home-shepherd-service-type home-shepherd-services))))) +;;; Gaming servicse + +(define-configuration/no-serialization home-gaming-configuration + (nvidia-driver? (boolean #f) "Adapt the installed packages for the +proprietary NVIDIA driver?")) + +(define (gaming-packages config) + (match-record config <home-gaming-configuration> (nvidia-driver?) + (if nvidia-driver? + ;; nvidia-system-monitor: Qt; installs "qnvsm" binary, but no .desktop file + (list steam-nvidia nvidia-system-monitor) + (list steam radeontop)))) + +(define (gaming-xdg-configs config) + `(("guix-gaming-channels/games.scm" + ,(scheme-file "guix-gaming-credentials.scm" + #~(begin + (use-modules (ice-9 rdelim) (ice-9 popen)) + (define gog-credentials + (let* ((pass (open-pipe* OPEN_READ "pass" "show" "software/games/gog")) + (password (read-line pass)) + (username + (let loop ((line (read-line pass))) + (cond + ((eof-object? line) + (error "Could not find username in pass output")) + ((string-prefix? "username: " line) + (string-trim + (substring line (string-length "username:")))) + (else (loop (read-line pass))))))) + (close-pipe pass) + `((email ,username) + (password ,password)))) + (make-gaming-config + `((gog ,gog-credentials)))))))) + +(define (gaming-environment config) + `(("GUIX_SANDBOX_EXTRA_SHARES" . ; mount savegame locations inside Steam container + ,(string-join + '("$HOME/savegames/banished=$HOME/.local/share/Steam/steamapps/compatdata/242920/pfx/drive_c/users/steamuser/Documents/Banished/Save" + "$HOME/savegames/planetbase=$HOME/.local/share/Steam/steamapps/compatdata/403190/pfx/drive_c/users/steamuser/Documents/Planetbase" + "$HOME/savegames/cities-skylines=$HOME/.local/share/Colossal Order/Cities_Skylines/Saves" + "$HOME/savegames/surviving-mars=$HOME/.local/share/Surviving Mars/76561198130982912" + "$HOME/savegames/colony-survival=$HOME/.local/share/Steam/steamapps/common/Colony Survival/gamedata/savegames" + "$HOME/savegames/portal=$HOME/.local/share/Steam/steamapps/common/Portal/portal/save" + "$HOME/savegames/spacechem=$HOME/.local/share/Zachtronics Industries/SpaceChem/save" + "$HOME/savegames/tis-100=$HOME/.local/share/TIS-100/76561198130982912") + ":")))) + +(define home-gaming-service-type + (service-type + (name 'gaming) + (description "Configure games and gaming platforms.") + (default-value (home-gaming-configuration)) + (extensions + (list (service-extension home-profile-service-type gaming-packages) + (service-extension home-xdg-configuration-files-service-type gaming-xdg-configs) + (service-extension home-environment-variables-service-type gaming-environment))))) + + ;; Personal Information Management (mail, calendar, contacts, etc) (define-configuration/no-serialization home-pim-configuration |