services: desktop: Use ‘define-configuration’.

This commit is contained in:
Hilton Chain 2025-06-26 20:02:52 +08:00
parent 20bac9c7a4
commit 7a185369e9
No known key found for this signature in database
GPG Key ID: ACC66D09CA528292

View File

@ -14,6 +14,7 @@
#:use-module (gnu services) #:use-module (gnu services)
#:use-module (gnu services base) #:use-module (gnu services base)
#:use-module (gnu services configuration)
#:use-module (gnu services desktop) #:use-module (gnu services desktop)
#:use-module (gnu services sddm) #:use-module (gnu services sddm)
#:use-module (gnu services xorg) #:use-module (gnu services xorg)
@ -74,15 +75,12 @@
;;; Blueman ;;; Blueman
;;; ;;;
(define-record-type* <home-blueman-applet-configuration> (define-configuration/no-serialization home-blueman-applet-configuration
home-blueman-applet-configuration (blueman
make-home-blueman-applet-configuration (file-like (spec->pkg+out "blueman"))
home-blueman-applet-configuration? ""))
this-home-blueman-applet-configuration
(blueman home-blueman-applet-configuration-blueman
(default (spec->pkg+out "blueman"))))
(define home-blueman-applet-shepherd-service (define %home-blueman-applet-shepherd
(match-record-lambda <home-blueman-applet-configuration> (match-record-lambda <home-blueman-applet-configuration>
(blueman) (blueman)
(list (shepherd-service (list (shepherd-service
@ -100,7 +98,7 @@
(list (service-extension home-profile-service-type (list (service-extension home-profile-service-type
(compose list home-blueman-applet-configuration-blueman)) (compose list home-blueman-applet-configuration-blueman))
(service-extension home-shepherd-service-type (service-extension home-shepherd-service-type
home-blueman-applet-shepherd-service))) %home-blueman-applet-shepherd)))
(default-value (home-blueman-applet-configuration)) (default-value (home-blueman-applet-configuration))
(description "Run blueman applet, a tray applet for managing bluetooth."))) (description "Run blueman applet, a tray applet for managing bluetooth.")))
@ -109,38 +107,32 @@
;;; Fcitx5 ;;; Fcitx5
;;; ;;;
(define-record-type* <home-fcitx5-configuration> (define list-of-file-likes?
home-fcitx5-configuration (list-of file-like?))
make-home-fcitx5-configuration (define-maybe file-like)
home-fcitx5-configuration?
this-home-fcitx5-configuration (define-configuration/no-serialization home-fcitx5-configuration
(fcitx5 home-fcitx5-configuration-fcitx5 (fcitx5
(default (spec->pkg "fcitx5"))) (file-like (spec->pkg "fcitx5"))
(utilities home-fcitx5-configuration-utilities "")
(default (specs->pkgs "fcitx5-configtool"))) (utilities
(themes home-fcitx5-configuration-themes (list-of-file-likes (specs->pkgs "fcitx5-configtool"))
(default '())) "")
(input-method-editors home-fcitx5-configuration-input-method-editors (themes
(default '())) (list-of-file-likes '())
(gtk-im-module? home-fcitx5-configuration-gtk-im-module? "")
(default #f)) (input-method-editors
(qt-im-module? home-fcitx5-configuration-qt-im-module? (list-of-file-likes '())
(default #f)) "")
(xim? home-fcitx5-configuration-xim? (gtk-im-module?
(default #t)) (boolean #f)
;; Extensions "")
(environment-variables home-fcitx5-configuration-environment-variables (qt-im-module?
(default (%home-fcitx5-environment-variables (boolean #f)
this-home-fcitx5-configuration)) "")
(thunked)) (xim?
(profile home-fcitx5-configuration-profile (boolean #t)
(default (%home-fcitx5-profile ""))
this-home-fcitx5-configuration))
(thunked))
(shepherd home-fcitx5-configuration-shepherd
(default (%home-fcitx5-shepherd
this-home-fcitx5-configuration))
(thunked)))
(define %home-fcitx5-environment-variables (define %home-fcitx5-environment-variables
(match-record-lambda <home-fcitx5-configuration> (match-record-lambda <home-fcitx5-configuration>
@ -186,11 +178,11 @@
(name 'fcitx5) (name 'fcitx5)
(extensions (extensions
(list (service-extension home-environment-variables-service-type (list (service-extension home-environment-variables-service-type
home-fcitx5-configuration-environment-variables) %home-fcitx5-environment-variables)
(service-extension home-profile-service-type (service-extension home-profile-service-type
home-fcitx5-configuration-profile) %home-fcitx5-profile)
(service-extension home-shepherd-service-type (service-extension home-shepherd-service-type
home-fcitx5-configuration-shepherd))) %home-fcitx5-shepherd)))
(default-value (home-fcitx5-configuration)) (default-value (home-fcitx5-configuration))
(description "Run fcitx5, an input method framework."))) (description "Run fcitx5, an input method framework.")))
@ -199,32 +191,21 @@
;;; mako ;;; mako
;;; ;;;
(define %rosenthal-example-mako-config (define-configuration/no-serialization home-mako-configuration
(local-file "../examples/mako.conf")) (mako
(file-like (spec->pkg "mako"))
(define-record-type* <home-mako-configuration> "")
home-mako-configuration (config
make-home-mako-configuration maybe-file-like
home-mako-configuration? "")
this-home-mako-configuration )
(mako home-mako-configuration-mako
(default (spec->pkg "mako")))
(config home-mako-configuration-config
(default %rosenthal-example-mako-config))
;; Extensions.
(xdg-config home-mako-configuration-xdg-config
(default (%home-mako-xdg-config
this-home-mako-configuration))
(thunked))
(shepherd home-mako-configuration-shepherd
(default (%home-mako-shepherd
this-home-mako-configuration))
(thunked)))
(define %home-mako-xdg-config (define %home-mako-xdg-config
(match-record-lambda <home-mako-configuration> (match-record-lambda <home-mako-configuration>
(config) (config)
`(("mako/config" ,config)))) (if (maybe-value-set? config)
`(("mako/config" ,config))
'())))
(define %home-mako-shepherd (define %home-mako-shepherd
(match-record-lambda <home-mako-configuration> (match-record-lambda <home-mako-configuration>
@ -242,9 +223,9 @@
(name 'mako) (name 'mako)
(extensions (extensions
(list (service-extension home-xdg-configuration-files-service-type (list (service-extension home-xdg-configuration-files-service-type
home-mako-configuration-xdg-config) %home-mako-xdg-config)
(service-extension home-shepherd-service-type (service-extension home-shepherd-service-type
home-mako-configuration-shepherd))) %home-mako-shepherd)))
(default-value (home-mako-configuration)) (default-value (home-mako-configuration))
(description "Run mako, a notification daemon."))) (description "Run mako, a notification daemon.")))
@ -253,15 +234,12 @@
;;; network-manager-applet ;;; network-manager-applet
;;; ;;;
(define-record-type* <home-network-manager-applet-configuration> (define-configuration/no-serialization home-network-manager-applet-configuration
home-network-manager-applet-configuration (network-manager-applet
make-home-network-manager-applet-configuration (file-like (spec->pkg "network-manager-applet"))
home-network-manager-applet-configuration? ""))
this-home-network-manager-applet-configuration
(network-manager-applet home-network-manager-applet-configuration-network-manager-applet
(default (spec->pkg "network-manager-applet"))))
(define home-network-manager-applet-shepherd-service (define %home-network-manager-applet-shepherd
(match-record-lambda <home-network-manager-applet-configuration> (match-record-lambda <home-network-manager-applet-configuration>
(network-manager-applet) (network-manager-applet)
(list (shepherd-service (list (shepherd-service
@ -279,7 +257,7 @@
(list (service-extension home-profile-service-type (list (service-extension home-profile-service-type
(compose list home-network-manager-applet-configuration-network-manager-applet)) (compose list home-network-manager-applet-configuration-network-manager-applet))
(service-extension home-shepherd-service-type (service-extension home-shepherd-service-type
home-network-manager-applet-shepherd-service))) %home-network-manager-applet-shepherd)))
(default-value (home-network-manager-applet-configuration)) (default-value (home-network-manager-applet-configuration))
(description "Run nm-applet, a tray applet for managing networks."))) (description "Run nm-applet, a tray applet for managing networks.")))
@ -288,40 +266,24 @@
;;; niri ;;; niri
;;; ;;;
(define %rosenthal-example-niri-config (define-configuration/no-serialization home-niri-configuration
(computed-substitution-with-inputs "niri.kdl" (config
(local-file "../examples/niri.kdl") maybe-file-like
(cons xwayland-satellite ""))
(specs->pkgs "alacritty"
"guix-backgrounds"
"light"
"rofi-wayland"
"wireplumber"))))
(define-record-type* <home-niri-configuration>
home-niri-configuration
make-home-niri-configuration
home-niri-configuration?
this-home-niri-configuration
(config home-niri-configuration-config
(default %rosenthal-example-niri-config))
;; Extension.
(xdg-config home-niri-configuration-xdg-config
(default (%home-niri-xdg-config
this-home-niri-configuration))
(thunked)))
(define %home-niri-xdg-config (define %home-niri-xdg-config
(match-record-lambda <home-niri-configuration> (match-record-lambda <home-niri-configuration>
(config) (config)
`(("niri/config.kdl" ,config)))) (if (maybe-value-set? config)
`(("niri/config.kdl" ,config))
'())))
(define home-niri-service-type (define home-niri-service-type
(service-type (service-type
(name 'niri) (name 'niri)
(extensions (extensions
(list (service-extension home-xdg-configuration-files-service-type (list (service-extension home-xdg-configuration-files-service-type
home-niri-configuration-xdg-config))) %home-niri-xdg-config)))
(default-value (home-niri-configuration)) (default-value (home-niri-configuration))
(description (description
"Set up configuration file for niri, a scrollable-tiling Wayland "Set up configuration file for niri, a scrollable-tiling Wayland
@ -332,38 +294,24 @@ compositor.")))
;;; rofi ;;; rofi
;;; ;;;
(define %rosenthal-example-rofi-config (define-configuration/no-serialization home-rofi-configuration
(mixed-text-file "rofi.rasi" "\ (config
configuration { maybe-file-like
icon-theme: \"Qogir\"; ""))
}
@theme \"" (spec->pkg "rofi-wayland") "/share/rofi/themes/fullscreen-preview.rasi\"\n"))
(define-record-type* <home-rofi-configuration>
home-rofi-configuration
make-home-rofi-configuration
home-rofi-configuration?
this-home-rofi-configuration
(config home-rofi-configuration-config
(default %rosenthal-example-rofi-config))
;; Extension.
(xdg-config home-rofi-configuration-xdg-config
(default (%home-rofi-xdg-config
this-home-rofi-configuration))
(thunked)))
(define %home-rofi-xdg-config (define %home-rofi-xdg-config
(match-record-lambda <home-rofi-configuration> (match-record-lambda <home-rofi-configuration>
(config) (config)
`(("rofi/config.rasi" ,config)))) (if (maybe-value-set? config)
`(("rofi/config.rasi" ,config))
'())))
(define home-rofi-service-type (define home-rofi-service-type
(service-type (service-type
(name 'rofi) (name 'rofi)
(extensions (extensions
(list (service-extension home-xdg-configuration-files-service-type (list (service-extension home-xdg-configuration-files-service-type
home-rofi-configuration-xdg-config))) %home-rofi-xdg-config)))
(default-value (home-rofi-configuration)) (default-value (home-rofi-configuration))
(description (description
"Set up configuration file for rofi, an application launcher."))) "Set up configuration file for rofi, an application launcher.")))
@ -373,20 +321,13 @@ configuration {
;;; swaybg ;;; swaybg
;;; ;;;
(define-record-type* <home-swaybg-configuration> (define-configuration/no-serialization home-swaybg-configuration
home-swaybg-configuration (swaybg
make-home-swaybg-configuration (file-like (spec->pkg "swaybg"))
home-swaybg-configuration? "")
this-home-swaybg-configuration (background
(swaybg home-swaybg-configuration-swaybg (file-like (local-file "../examples/wallpaper.jpg"))
(default (spec->pkg "swaybg"))) ""))
(background home-swaybg-configuration-background
(default (local-file "../examples/wallpaper.jpg")))
;; Extensions.
(shepherd home-swaybg-configuration-shepherd
(default (%home-swaybg-shepherd
this-home-swaybg-configuration))
(thunked)))
(define %home-swaybg-shepherd (define %home-swaybg-shepherd
(match-record-lambda <home-swaybg-configuration> (match-record-lambda <home-swaybg-configuration>
@ -405,7 +346,7 @@ configuration {
(name 'swaybg) (name 'swaybg)
(extensions (extensions
(list (service-extension home-shepherd-service-type (list (service-extension home-shepherd-service-type
home-swaybg-configuration-shepherd))) %home-swaybg-shepherd)))
(default-value (home-swaybg-configuration)) (default-value (home-swaybg-configuration))
(description (description
"Run swaybg, a screen wallpaper utility for Wayland compositors."))) "Run swaybg, a screen wallpaper utility for Wayland compositors.")))
@ -415,38 +356,22 @@ configuration {
;;; theme ;;; theme
;;; ;;;
(define-record-type* <home-theme-configuration> (define-configuration/no-serialization home-theme-configuration
home-theme-configuration (packages
make-home-theme-configuration (list-of-file-likes '())
home-theme-configuration? "")
this-home-theme-configuration (icon-theme
(packages home-theme-configuration-packages (string "Adwaita")
(default '())) "")
(icon-theme home-theme-configuration-icon-theme (cursor-theme
(default "Adwaita")) (string "Adwaita")
(cursor-theme home-theme-configuration-cursor-theme "")
(default "Adwaita")) (cursor-size
(cursor-size home-theme-configuration-cursor-size (number 24)
(default 24)) "")
(key-theme home-theme-configuration-key-theme (key-theme
(default "Default")) (string "Default")
;; Extensions. ""))
(environment-variables home-theme-configuration-environment-variables
(default (%home-theme-environment-variables
this-home-theme-configuration))
(thunked))
(profile home-theme-configuration-profile
(default (%home-theme-profile
this-home-theme-configuration))
(thunked))
(files home-theme-configuration-files
(default (%home-theme-files
this-home-theme-configuration))
(thunked))
(xdg-config home-theme-configuration-xdg-config
(default (%home-theme-xdg-config
this-home-theme-configuration))
(thunked)))
(define (%home-theme-environment-variables _) (define (%home-theme-environment-variables _)
'(("QT_QPA_PLATFORMTHEME" . "gtk3") '(("QT_QPA_PLATFORMTHEME" . "gtk3")
@ -465,7 +390,7 @@ configuration {
(icon-theme) (icon-theme)
`((".icons/default/index.theme" `((".icons/default/index.theme"
,(plain-file "index.theme" ,(plain-file "index.theme"
(format #f "~ (format #f "\
[icon theme] [icon theme]
Inherits = ~a~%" Inherits = ~a~%"
icon-theme)))))) icon-theme))))))
@ -475,7 +400,7 @@ Inherits = ~a~%"
(icon-theme cursor-theme cursor-size key-theme) (icon-theme cursor-theme cursor-size key-theme)
`(("gtk-3.0/settings.ini" `(("gtk-3.0/settings.ini"
,(plain-file "settings.ini" ,(plain-file "settings.ini"
(format #f "~ (format #f "\
[Settings] [Settings]
gtk-theme-name = Adwaita gtk-theme-name = Adwaita
gtk-icon-theme-name = ~a gtk-icon-theme-name = ~a
@ -490,13 +415,13 @@ gtk-key-theme-name = ~a~%"
(name 'theme) (name 'theme)
(extensions (extensions
(list (service-extension home-environment-variables-service-type (list (service-extension home-environment-variables-service-type
home-theme-configuration-environment-variables) %home-theme-environment-variables)
(service-extension home-profile-service-type (service-extension home-profile-service-type
home-theme-configuration-profile) %home-theme-profile)
(service-extension home-files-service-type (service-extension home-files-service-type
home-theme-configuration-files) %home-theme-files)
(service-extension home-xdg-configuration-files-service-type (service-extension home-xdg-configuration-files-service-type
home-theme-configuration-xdg-config))) %home-theme-xdg-config)))
(default-value (home-theme-configuration)) (default-value (home-theme-configuration))
(description "Set up desktop themes."))) (description "Set up desktop themes.")))
@ -505,40 +430,26 @@ gtk-key-theme-name = ~a~%"
;;; waybar ;;; waybar
;;; ;;;
(define %rosenthal-example-waybar-config (define-configuration/no-serialization home-waybar-configuration
(computed-substitution-with-inputs "config.jsonc" (waybar
(local-file "../examples/waybar/config.jsonc") (file-like (spec->pkg "waybar"))
(specs->pkgs "light" "pavucontrol" "wireplumber"))) "")
(config
(define %rosenthal-example-waybar-style maybe-file-like
(local-file "../examples/waybar/style.css")) "")
(style
(define-record-type* <home-waybar-configuration> maybe-file-like
home-waybar-configuration ""))
make-home-waybar-configuration
home-waybar-configuration?
this-home-waybar-configuration
(waybar home-waybar-configuration-waybar
(default (spec->pkg "waybar")))
(config home-waybar-configuration-config
(default %rosenthal-example-waybar-config))
(style home-waybar-configuration-style
(default %rosenthal-example-waybar-style))
;; Extensions.
(xdg-config home-waybar-configuration-xdg-config
(default (%home-waybar-xdg-config
this-home-waybar-configuration))
(thunked))
(shepherd home-waybar-configuration-shepherd
(default (%home-waybar-shepherd
this-home-waybar-configuration))
(thunked)))
(define %home-waybar-xdg-config (define %home-waybar-xdg-config
(match-record-lambda <home-waybar-configuration> (match-record-lambda <home-waybar-configuration>
(config style) (config style)
`(("waybar/config.jsonc" ,config) `(,@(if (maybe-value-set? config)
("waybar/style.css" ,style)))) `(("waybar/config.jsonc" ,config))
'())
,@(if (maybe-value-set? style)
`(("waybar/style.css" ,style))
'()))))
(define %home-waybar-shepherd (define %home-waybar-shepherd
(match-record-lambda <home-waybar-configuration> (match-record-lambda <home-waybar-configuration>
@ -556,9 +467,9 @@ gtk-key-theme-name = ~a~%"
(name 'waybar) (name 'waybar)
(extensions (extensions
(list (service-extension home-xdg-configuration-files-service-type (list (service-extension home-xdg-configuration-files-service-type
home-waybar-configuration-xdg-config) %home-waybar-xdg-config)
(service-extension home-shepherd-service-type (service-extension home-shepherd-service-type
home-waybar-configuration-shepherd))) %home-waybar-shepherd)))
(default-value (home-waybar-configuration)) (default-value (home-waybar-configuration))
(description "Run waybar, a status bar for Wayland compositors."))) (description "Run waybar, a status bar for Wayland compositors.")))