;;; Copyright © 2013, 2014, 2015, 2016, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017 Clément Lassieur <clement@lassieur.org>
;;; Copyright © 2018 Carlo Zancanaro <carlo@zancanaro.id.au>
+;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
#:use-module (guix store)
#:use-module (guix records)
#:use-module (guix derivations) ;imported-modules, etc.
+ #:use-module (guix utils)
#:use-module (gnu services)
#:use-module (gnu services herd)
#:use-module (gnu packages admin)
(extensions (list (service-extension boot-service-type
shepherd-boot-gexp)
(service-extension profile-service-type
- (const (list shepherd)))))))
+ (const (list shepherd)))))
+ (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
;; Default set of modules visible in a service's file.
`((shepherd service)
(oop goops)
- (guix build utils)
+ ((guix build utils) #:hide (delete))
(guix build syscalls)))
(define-record-type* <shepherd-service>
(define (scm->go file)
"Compile FILE, which contains code to be loaded by shepherd's config file,
and return the resulting '.go' file."
- (with-extensions (list shepherd)
- (computed-file (string-append (basename (scheme-file-name file) ".scm")
- ".go")
- #~(begin
- (use-modules (system base compile))
-
- ;; Do the same as the Shepherd's 'load-in-user-module'.
- (let ((env (make-fresh-user-module)))
- (module-use! env (resolve-interface '(oop goops)))
- (module-use! env (resolve-interface '(shepherd service)))
- (compile-file #$file #:output-file #$output
- #:env env)))
-
- ;; It's faster to build locally than to download.
- #:options '(#:local-build? #t
- #:substitutable? #f))))
+ (let-system (system target)
+ (with-extensions (list shepherd)
+ (computed-file (string-append (basename (scheme-file-name file) ".scm")
+ ".go")
+ #~(begin
+ (use-modules (system base compile)
+ (system base target))
+
+ ;; Do the same as the Shepherd's 'load-in-user-module'.
+ (let ((env (make-fresh-user-module)))
+ (module-use! env (resolve-interface '(oop goops)))
+ (module-use! env (resolve-interface '(shepherd service)))
+ (with-target #$(or target #~%host-type)
+ (lambda _
+ (compile-file #$file #:output-file #$output
+ #:env env)))))
+
+ ;; It's faster to build locally than to download.
+ #:options '(#:local-build? #t
+ #:substitutable? #f)))))
(define (shepherd-configuration-file services)
"Return the shepherd configuration file for SERVICES."
(call-with-error-handling
(lambda ()
(apply register-services
- (map load-compiled '#$(map scm->go files)))))
+ (parameterize ((current-warning-port
+ (%make-void-port "w")))
+ (map load-compiled '#$(map scm->go files))))))
(format #t "starting services...~%")
(for-each (lambda (service)