janneke pushed a commit to branch wip-hurd-vm
in repository guix.
commit 7f2212b42033bad6a930c126e812a3b373ff4838
Author: Jan (janneke) Nieuwenhuizen <[email protected]>
AuthorDate: Mon Apr 13 10:36:56 2020 +0200
DRAFT services: Add hurd-ttys-service-type.
XXX remove hurd-service->shepherd-service
TODO: Add entry in the manual.
* gnu/services/hurd.scm (<hurd-ttys-configuration>): New variable.
(hurd-ttys-shepherd-service, hurd-ttys-service-type): New function.
(hurd-service->shepherd-service): Add entry.
---
gnu/services/hurd.scm | 43 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 41 insertions(+), 2 deletions(-)
diff --git a/gnu/services/hurd.scm b/gnu/services/hurd.scm
index be4bab0..4f32cce 100644
--- a/gnu/services/hurd.scm
+++ b/gnu/services/hurd.scm
@@ -26,8 +26,11 @@
#:use-module (guix records)
#:use-module (srfi srfi-1)
#:use-module (ice-9 match)
- #:export (hurd-console-service-type
- hurd-service->shepherd-service))
+ #:export (hurd-console-configuration
+ hurd-console-service-type
+ hurd-service->shepherd-service
+ hurd-ttys-configuration
+ hurd-ttys-service-type))
;;; Commentary:
;;;
@@ -40,6 +43,7 @@
(let ((config (service-value service)))
(match config
(($ <hurd-console-configuration>) (hurd-console-shepherd-service config))
+ (($ <hurd-ttys-configuration>) (hurd-ttys-shepherd-service config))
(_ '()))))
(define (first-of-two first second)
@@ -83,4 +87,39 @@
hurd-console-shepherd-service)))
(default-value (hurd-console-configuration))))
+
+;;;
+;;; Simple wrapper for <hurd>/libexec/runttys.
+;;;
+
+(define-record-type* <hurd-ttys-configuration>
+ hurd-ttys-configuration make-hurd-ttys-configuration
+ hurd-ttys-configuration?
+ (hurd hurd-ttys-configuration-hurd ;package
+ (default hurd)))
+
+(define (hurd-ttys-shepherd-service config)
+ "Return a <shepherd-service> for the Hurd ttys with CONFIG."
+
+ (define runttys-command
+ #~(list
+ (string-append #$(hurd-ttys-configuration-hurd config)
"/libexec/runttys")))
+
+ (list (shepherd-service
+ (documentation "Run the Hurd's runttys daemon.")
+ (provision '(ttys))
+ (requirement '(console))
+ (start #~(make-forkexec-constructor #$runttys-command))
+ (stop #~(make-kill-destructor)))))
+
+(define hurd-ttys-service-type
+ (service-type
+ (name 'tty)
+ (description
+ "Run the Hurd runttys daemon.")
+ (extensions
+ (list (service-extension shepherd-root-service-type
+ hurd-ttys-shepherd-service)))
+ (default-value (hurd-ttys-configuration))))
+
;;; hurd.scm ends here