[PATCH] gnu: services: Add joycond-service.

  • Done
  • quality assurance status badge
Details
2 participants
  • Thompson, David
  • Bruno Victal
Owner
unassigned
Submitted by
Thompson, David
Severity
normal

Debbugs page

Thompson, David wrote 2 years ago
(address . guix-patches@gnu.org)
CAJ=RwfZCC=7ZdF2WNs5kGcPh38fub6xN6JbbFew1Q7VD-Yk-Ww@mail.gmail.com
Hello Guix,

Joycond is a handy daemon for pairing bluetooth controllers made by
Nintendo. Someone already did the hard work of packaging it, so I
added this simple service to make it easy to use as a system service.

WDYT?

- Dave
From 247ce9cd302d3ff196eae662d27f5a37ac6ce376 Mon Sep 17 00:00:00 2001
From: David Thompson <dthompson2@worcester.edu>
Date: Fri, 13 Jan 2023 17:04:21 -0500
Subject: [PATCH] gnu: services: Add joycond-service.

* gnu/services/games.scm (<joycond-configuration>): New record type.
(joycond-configuration, joycond-configuration?, joycond-configuration-joycond,
joycond-shepherd-service): New procedures.
(joycond-service-type): New variable.
* doc/guix.texi (Game Services): Document it.
---
doc/guix.texi | 19 +++++++++++++++++++
gnu/services/games.scm | 37 ++++++++++++++++++++++++++++++++++++-
2 files changed, 55 insertions(+), 1 deletion(-)

Toggle diff (83 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 751d0957d8..4aec5895d2 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -36277,6 +36277,25 @@ like to serve.
@node Game Services
@subsection Game Services
+@subsubheading Joycond service
+@cindex joycond
+The joycond service allows the pairing of Nintendo joycon game
+controllers over Bluetooth. (@pxref{Desktop Services} for setting up
+Bluetooth.)
+
+@deftp {Data Type} joycond-configuration
+Data type representing the configuration of @command{joycond}.
+
+@table @asis
+@item @code{joycond} (default: @code{joycond})
+The joycond package to use.
+@end table
+@end deftp
+
+@defvar {Scheme Variable} joycond-service-type
+Service type for the joycond service.
+@end defvar
+
@subsubheading The Battle for Wesnoth Service
@cindex wesnothd
@uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
diff --git a/gnu/services/games.scm b/gnu/services/games.scm
index 6c2af44b49..adccddfb99 100644
--- a/gnu/services/games.scm
+++ b/gnu/services/games.scm
@@ -30,10 +30,45 @@ (define-module (gnu services games)
#:use-module (guix modules)
#:use-module (guix records)
#:use-module (ice-9 match)
- #:export (wesnothd-configuration
+ #:export (joycond-configuration
+ joycond-configuration?
+ joycond-configuration-joycond
+ joycond-service-type
+
+ wesnothd-configuration
wesnothd-configuration?
wesnothd-service-type))
+;;;
+;;; Joycond
+;;;
+
+(define-record-type* <joycond-configuration>
+ joycond-configuration make-joycond-configuration
+ joycond-configuration?
+ (joycond joycond-configuration-joycond (default joycond)))
+
+(define (joycond-shepherd-service config)
+ (let ((joycond (joycond-configuration-joycond config)))
+ (list (shepherd-service
+ (documentation "Run joycond.")
+ (provision '(joycond))
+ (requirement '(bluetooth))
+ (start #~(make-forkexec-constructor
+ (list #$(file-append joycond "/bin/joycond"))))
+ (stop #~(make-kill-destructor))))))
+
+(define joycond-service-type
+ (service-type
+ (name 'joycond)
+ (description
+ "Run @command{joycond} for pairing Nintendo joycons via Bluetooth.")
+ (extensions
+ (list (service-extension shepherd-root-service-type
+ joycond-shepherd-service)))
+ (default-value (joycond-configuration))))
+
+
;;;
;;; The Battle for Wesnoth server
;;;
--
2.38.1
Bruno Victal wrote 2 years ago
(address . 60791@debbugs.gnu.org)(address . dthompson2@worcester.edu)
5eaac013-2a20-c322-24a9-ab389ec974c5@makinata.eu
Hi,

Toggle snippet (5 lines)
+@defvar {Scheme Variable} joycond-service-type
+Service type for the joycond service.
+@end defvar

Should be `@defvar joycond-service-type'.

Toggle snippet (6 lines)
+(define-record-type* <joycond-configuration>
+ joycond-configuration make-joycond-configuration
+ joycond-configuration?
+ (joycond joycond-configuration-joycond (default joycond)))

This could be replaced with define-configuration/no-serialization since
the only field here is a package / file-like object. (see [1], [2] for examples)
I'd prefer the field be called 'package' here.

Toggle snippet (11 lines)
+(define (joycond-shepherd-service config)
+ (let ((joycond (joycond-configuration-joycond config)))
+ (list (shepherd-service
+ (documentation "Run joycond.")
+ (provision '(joycond))
+ (requirement '(bluetooth))
+ (start #~(make-forkexec-constructor
+ (list #$(file-append joycond "/bin/joycond"))))
+ (stop #~(make-kill-destructor))))))

You might prefer match-record here but this is okay as well.


[2]: ddclient-configuration in gnu/services/dns.scm


Cheers,
Bruno
Thompson, David wrote 2 years ago
(address . mirai@makinata.eu)(address . 60791@debbugs.gnu.org)
CAJ=RwfYaAKCwomnaF_AURPOOBziKUcq4nWxkv+f1cM7ytSoJ-A@mail.gmail.com
Hi Bruno,

Thanks for the review!

On Fri, Jan 13, 2023 at 5:46 PM Bruno Victal <mirai@makinata.eu> wrote:
Toggle quote (11 lines)
>
> Hi,
>
> --8<---------------cut here---------------start------------->8---
> +@defvar {Scheme Variable} joycond-service-type
> +Service type for the joycond service.
> +@end defvar
> --8<---------------cut here---------------end--------------->8---
>
> Should be `@defvar joycond-service-type'.

Oh, okay. Guess I missed that change in convention. There's lots of
'@defvar {Scheme Variable}' in the manual.

Toggle quote (11 lines)
> --8<---------------cut here---------------start------------->8---
> +(define-record-type* <joycond-configuration>
> + joycond-configuration make-joycond-configuration
> + joycond-configuration?
> + (joycond joycond-configuration-joycond (default joycond)))
> --8<---------------cut here---------------end--------------->8---
>
> This could be replaced with define-configuration/no-serialization since
> the only field here is a package / file-like object. (see [1], [2] for examples)
> I'd prefer the field be called 'package' here.

Ahhhh unhygienic macros! Not a fan but I see that this macro is the
preferred thing these days so okay, changed! I also prefer the field
to be called 'package' so I've changed it! When I looked around at
some other services they used the package name as the field name so I
followed their lead.

Toggle quote (14 lines)
> --8<---------------cut here---------------start------------->8---
> +(define (joycond-shepherd-service config)
> + (let ((joycond (joycond-configuration-joycond config)))
> + (list (shepherd-service
> + (documentation "Run joycond.")
> + (provision '(joycond))
> + (requirement '(bluetooth))
> + (start #~(make-forkexec-constructor
> + (list #$(file-append joycond "/bin/joycond"))))
> + (stop #~(make-kill-destructor))))))
> --8<---------------cut here---------------end--------------->8---
>
> You might prefer match-record here but this is okay as well.

If I was destructuring many record fields I'd use it.

Updated patch attached.

Thanks!

- Dave
Bruno Victal wrote 2 years ago
(name . Thompson, David)(address . dthompson2@worcester.edu)(address . 60791@debbugs.gnu.org)
ddfb534d-6a3c-039e-7dcf-5386551e0e81@makinata.eu
Toggle snippet (3 lines)
joycond-configuration-joycond

Doesn't need to be exported, commit message could be amended as well.


Toggle snippet (7 lines)
+@table @asis
+@item @code{joycond} (default: @code{joycond})
+The joycond package to use.
+@end table
+@end deftp

@code should be updated to the new `package' field name.


Overall LTGM.


Cheers,
Bruno
Thompson, David wrote 2 years ago
(name . Bruno Victal)(address . mirai@makinata.eu)(address . 60791-done@debbugs.gnu.org)
CAJ=RwfYmj7nn-vFC1GTHUL+=aNs1FHSMGVrgcQXGzSThJgHQig@mail.gmail.com
On Fri, Jan 13, 2023 at 11:47 PM Bruno Victal <mirai@makinata.eu> wrote:
Toggle quote (21 lines)
>
> --8<---------------cut here---------------start------------->8---
> joycond-configuration-joycond
> --8<---------------cut here---------------end--------------->8---
>
> Doesn't need to be exported, commit message could be amended as well.
>
>
> --8<---------------cut here---------------start------------->8---
> +@table @asis
> +@item @code{joycond} (default: @code{joycond})
> +The joycond package to use.
> +@end table
> +@end deftp
> --8<---------------cut here---------------end--------------->8---
>
> @code should be updated to the new `package' field name.
>
>
> Overall LTGM.

Thanks for catching my silly late-evening fixup oversights. Fixed all
of that and pushed!

- Dave
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 60791@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 60791
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help