From 211a50352227ef8fa98bc45b2248937ab602fff1 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 21 Jan 2021 16:05:37 +0100 Subject: system: Fix typo in docstring. * gnu/system.scm (operating-system-etc-service): Fix typo. --- gnu/system.scm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gnu/system.scm') diff --git a/gnu/system.scm b/gnu/system.scm index c284a18379..90ad368664 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès +;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès ;;; Copyright © 2015 Mark H Weaver ;;; Copyright © 2015, 2016 Alex Kost ;;; Copyright © 2016 Chris Marusich @@ -858,8 +858,8 @@ syntactically correct." (copy-file #$file #$output))))) (define* (operating-system-etc-service os) - "Return a that builds containing the static part of the /etc -directory." + "Return a that builds a directory containing the static part of +the /etc directory." (let* ((login.defs (plain-file "login.defs" (string-append -- cgit v1.2.3 From 95f72dcd7aece05e9252c93bef5a831f96cb5393 Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Fri, 22 Jan 2021 20:06:55 +0100 Subject: services: shepherd: Allow custom 'shepherd' package. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/services/shepherd.scm (): New record. (shepherd-boot-gexp, shepherd-root-service-type): Use it. (scm->go, shepherd-configuration-file): Allow passing custom shepherd package. * gnu/system.scm (operating-system-shepherd-service-names): Use the new record. * guix/scripts/system.scm (export-shepherd-graph): Adjust accordingly. * doc/guix.texi (Shepherd Services). Document it. Co-authored-by: Ludovic Courtès --- doc/guix.texi | 17 ++++++++++++++- gnu/services/shepherd.scm | 53 +++++++++++++++++++++++++++++++++++------------ gnu/system.scm | 10 +++++---- guix/scripts/system.scm | 3 ++- 4 files changed, 64 insertions(+), 19 deletions(-) (limited to 'gnu/system.scm') diff --git a/doc/guix.texi b/doc/guix.texi index 9b65be3c9c..405b218289 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -32782,9 +32782,24 @@ The service type for the Shepherd ``root service''---i.e., PID@tie{}1. This is the service type that extensions target when they want to create shepherd services (@pxref{Service Types and Services}, for an example). -Each extension must pass a list of @code{}. +Each extension must pass a list of @code{}. Its +value must be a @code{shepherd-configuration}, as described below. @end defvr +@deftp {Data Type} shepherd-configuration +This data type represents the Shepherd's configuration. + +@table @code +@item shepherd (default: @code{shepherd}) +The Shepherd package to use. + +@item services (default: @code{'()}) +A list of @code{} to start. +You should probably use the service extension +mechanism instead (@pxref{Shepherd Services}). +@end table +@end deftp + @defvr {Scheme Variable} %shepherd-root-service This service represents PID@tie{}1. @end defvr diff --git a/gnu/services/shepherd.scm b/gnu/services/shepherd.scm index d2f9776288..e2ec59f5aa 100644 --- a/gnu/services/shepherd.scm +++ b/gnu/services/shepherd.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2017 Clément Lassieur ;;; Copyright © 2018 Carlo Zancanaro ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen +;;; Copyright © 2021 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -36,7 +37,12 @@ #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) - #:export (shepherd-root-service-type + #:export (shepherd-configuration + shepherd-configuration? + shepherd-configuration-shepherd + shepherd-configuration-services + + shepherd-root-service-type %shepherd-root-service shepherd-service-type @@ -76,7 +82,18 @@ ;;; Code: -(define (shepherd-boot-gexp services) +(define-record-type* + shepherd-configuration make-shepherd-configuration + shepherd-configuration? + (shepherd shepherd-configuration-shepherd + (default shepherd)) ; package + (services shepherd-configuration-services + (default '()))) ; list of + +(define (shepherd-boot-gexp config) + "Return a gexp starting the shepherd service." + (let ((shepherd (shepherd-configuration-shepherd config)) + (services (shepherd-configuration-services config))) #~(begin ;; Keep track of the booted system. (false-if-exception (delete-file "/run/booted-system")) @@ -95,7 +112,10 @@ ;; Start shepherd. (execl #$(file-append shepherd "/bin/shepherd") "shepherd" "--config" - #$(shepherd-configuration-file services)))) + #$(shepherd-configuration-file services shepherd))))) + +(define shepherd-packages + (compose list shepherd-configuration-shepherd)) (define shepherd-root-service-type (service-type @@ -103,20 +123,25 @@ ;; Extending the root shepherd service (aka. PID 1) happens by ;; concatenating the list of services provided by the extensions. (compose concatenate) - (extend append) + (extend (lambda (config extra-services) + (shepherd-configuration + (inherit config) + (services (append (shepherd-configuration-services config) + extra-services))))) (extensions (list (service-extension boot-service-type shepherd-boot-gexp) (service-extension profile-service-type - (const (list shepherd))))) + shepherd-packages))) + (default-value (shepherd-configuration)) (description "Run the GNU Shepherd as PID 1---i.e., the operating system's first process. The Shepherd takes care of managing services such as daemons by ensuring they are started and stopped in the right order."))) (define %shepherd-root-service - ;; The root shepherd service, aka. PID 1. Its parameter is a list of - ;; objects. - (service shepherd-root-service-type '())) + ;; The root shepherd service, aka. PID 1. Its parameter is a + ;; . + (service shepherd-root-service-type)) (define-syntax shepherd-service-type (syntax-rules (description) @@ -270,9 +295,9 @@ stored." #~(#$name #$doc #$proc))) (shepherd-service-actions service)))))))) -(define (scm->go file) +(define (scm->go file shepherd) "Compile FILE, which contains code to be loaded by shepherd's config file, -and return the resulting '.go' file." +and return the resulting '.go' file. SHEPHERD is used as shepherd package." (let-system (system target) (with-extensions (list shepherd) (computed-file (string-append (basename (scheme-file-name file) ".scm") @@ -294,11 +319,13 @@ and return the resulting '.go' file." #:options '(#:local-build? #t #:substitutable? #f))))) -(define (shepherd-configuration-file services) - "Return the shepherd configuration file for SERVICES." +(define (shepherd-configuration-file services shepherd) + "Return the shepherd configuration file for SERVICES. SHEPHERD is used +as shepherd package." (assert-valid-graph services) - (let ((files (map shepherd-service-file services))) + (let ((files (map shepherd-service-file services)) + (scm->go (cute scm->go <> shepherd))) (define config #~(begin (use-modules (srfi srfi-34) diff --git a/gnu/system.scm b/gnu/system.scm index 90ad368664..5bf2a85272 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -12,6 +12,7 @@ ;;; Copyright © 2020 Maxim Cournoyer ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2020 Efraim Flashner +;;; Copyright © 2021 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -1134,10 +1135,11 @@ we're running in the final root." (define (operating-system-shepherd-service-names os) "Return the list of Shepherd service names for OS." (append-map shepherd-service-provision - (service-value - (fold-services (operating-system-services os) - #:target-type - shepherd-root-service-type)))) + (shepherd-configuration-services + (service-value + (fold-services (operating-system-services os) + #:target-type + shepherd-root-service-type))))) (define* (operating-system-derivation os) "Return a derivation that builds OS." diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 66225bff35..19b8c5163c 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -915,7 +915,8 @@ Run 'herd status' to view the list of services on your system.\n")))))) (let* ((services (operating-system-services os)) (pid1 (fold-services services #:target-type shepherd-root-service-type)) - (shepherds (service-value pid1)) ;list of + ;; Get the list of . + (shepherds (shepherd-configuration-services (service-value pid1))) (sinks (filter (lambda (service) (null? (shepherd-service-requirement service))) shepherds))) -- cgit v1.2.3