Subject: [bug#76060] [PATCH] gnu: home: services: Add 'wayland-display' service.

From: Ludovic Courtès <[email-masked]>
Date: Wed, 05 Feb 2025 22:48:07 +0100

Hello,

(Cc’ing members of the Home team.)

Sisiutl <[email-masked]> skribis:

> * gnu/home/services/desktop.scm (wayland-shepherd-service): New procedure.
> (home-wayland-service-type): New variable.
>
> Change-Id: Ide1ca748551a280efe8286b4ac1e46787b108443

Nice improvement.

> -
> +
>  ;;;
>  ;;; Waiting for X11.

These ^L characters are page breaks, which are useful when navigating
through the file; please preserve them.

> +(define (wayland-shepherd-service config)

[...]

> +         (respawn? #t)
> +         (respawn-limit (home-wayland-configuration-tries config))
> +         (respawn-delay 1)

I believe ‘home-wayland-configuration-tries’ does not exist.

But I think you can remove these three lines because respawning only
applies to services that start a daemon, which is not the case here.

> +              (define (socket? directory regex)
> +                (find (match-lambda
> +                        ((or "." "..") #f)
> +                        (name
> +                         (let ((name (in-vicinity directory
> +                                                  name)))
> +                           (and (string-match regex name)
> +                                (access? name O_RDWR)))))
> +                      ;; Wayland names its sockets `wayland-n`. With
> +                      ;; `reverse`, we pick up on the last Wayland instance
> +                      ;; created (essentially what we always want to do).
> +                      (or (reverse (scandir directory)) '())))

I think ‘find-socket’ would be a better name than ‘socket?’.

Nitpick: prefer 'straight quotes' or ‘curly quotes’ in comments.

> +(define-public home-wayland-service-type

Please use plain ‘define’ and add to the export list at the top.

> +  (service-type
> +   (name 'home-wayland-display)
> +   (extensions (list (service-extension home-shepherd-service-type
> +                                        wayland-shepherd-service)))
> +   (default-value 10)

I believe this value is unused.  Maybe set it to #f for clarity.

One last thing: could you add a note in ‘doc/guix.texi’ about this
service, right after ‘home-x11-service-type’?

Thanks in advance!

Ludo’.