services: home-niri: Validate configuration file.

* modules/rosenthal/services/desktop.scm
  (home-niri-configuration) [niri]: New field.
  (home-niri-service-type): Extend home-profile-service-type with it.
  (validated-niri-config): New procedure.
  (%home-niri-xdg-config): Use it.
This commit is contained in:
Hilton Chain committed 2026-10-20 14:22:18 +08:00
1 parent e1b25f7d8d
commit 276eca71dd
1 file changed
+17 -3
+17 -3
View File
@@ -354,22 +354,36 @@
;;;
(define-configuration/no-serialization home-niri-configuration
(niri
(file-like niri)
"")
(config
maybe-file-like
""))
(define (validated-niri-config niri file)
(computed-file "niri.kdl"
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils))
(invoke #+(file-append niri "/bin/niri") "validate"
"--config" #$file)
(copy-file #$file #$output)))))
(define %home-niri-xdg-config
(match-record-lambda <home-niri-configuration>
(config)
(niri config)
(if (maybe-value-set? config)
`(("niri/config.kdl" ,config))
`(("niri/config.kdl" ,(validated-niri-config niri config)))
'())))
(define home-niri-service-type
(service-type
(name 'home-niri)
(extensions
(list (service-extension home-xdg-configuration-files-service-type
(list (service-extension home-profile-service-type
(compose list home-niri-configuration-niri))
(service-extension home-xdg-configuration-files-service-type
%home-niri-xdg-config)))
(default-value (home-niri-configuration))
(description