services: Use (guix build syscalls) instead of util-linux.

* gnu/services/dmd.scm (dmd-configuration-file): Add derivations for
  the (guix build syscalls) module, and add that to the load path of
  dmd.conf.
* gnu/services/base.scm (root-file-system-service): Rewrite using the
  'sync' and 'mount' procedures.
This commit is contained in:
Ludovic Courtès 2014-05-10 22:58:22 +02:00
parent 29fa45f45d
commit 23ed63a12d
2 changed files with 38 additions and 29 deletions

View File

@ -22,8 +22,7 @@
#:use-module (gnu system linux) ; 'pam-service', etc. #:use-module (gnu system linux) ; 'pam-service', etc.
#:use-module (gnu packages admin) #:use-module (gnu packages admin)
#:use-module ((gnu packages base) #:use-module ((gnu packages base)
#:select (glibc-final %final-inputs)) #:select (glibc-final))
#:use-module (gnu packages linux)
#:use-module (gnu packages package-management) #:use-module (gnu packages package-management)
#:use-module (guix gexp) #:use-module (guix gexp)
#:use-module (guix monads) #:use-module (guix monads)
@ -52,9 +51,6 @@ system upon shutdown (aka. cleanly \"umounting\" root.)
This service must be the root of the service dependency graph so that its This service must be the root of the service dependency graph so that its
'stop' action is invoked when dmd is the only process left." 'stop' action is invoked when dmd is the only process left."
(define coreutils
(car (assoc-ref %final-inputs "coreutils")))
(with-monad %store-monad (with-monad %store-monad
(return (return
(service (service
@ -63,7 +59,7 @@ This service must be the root of the service dependency graph so that its
(start #~(const #t)) (start #~(const #t))
(stop #~(lambda _ (stop #~(lambda _
;; Return #f if successfully stopped. ;; Return #f if successfully stopped.
(system* (string-append #$coreutils "/bin/sync")) (sync)
(call-with-blocked-asyncs (call-with-blocked-asyncs
(lambda () (lambda ()
@ -82,12 +78,13 @@ This service must be the root of the service dependency graph so that its
;; Close /dev/console. ;; Close /dev/console.
(for-each close-fdes '(0 1 2)) (for-each close-fdes '(0 1 2))
;; At this points, there are no open files left, so the ;; At this point, there are no open files left, so the
;; root file system can be re-mounted read-only. ;; root file system can be re-mounted read-only.
(not (zero? (mount #f "/" #f
(system* (string-append #$util-linux "/bin/mount") (logior MS_REMOUNT MS_RDONLY)
"-n" "-o" "remount,ro" #:update-mtab? #f)
"-t" "dummy" "dummy" "/"))))))))
#f)))))
(respawn? #f))))) (respawn? #f)))))
(define* (user-processes-service #:key (grace-delay 2)) (define* (user-processes-service #:key (grace-delay 2))

View File

@ -32,27 +32,39 @@
(define (dmd-configuration-file services) (define (dmd-configuration-file services)
"Return the dmd configuration file for SERVICES." "Return the dmd configuration file for SERVICES."
(define config (define modules
#~(begin ;; Extra modules visible to dmd.conf.
(use-modules (ice-9 ftw)) '((guix build syscalls)))
(register-services (mlet %store-monad ((modules (imported-modules modules))
#$@(map (lambda (service) (compiled (compiled-modules modules)))
#~(make <service> (define config
#:docstring '#$(service-documentation service) #~(begin
#:provides '#$(service-provision service) (eval-when (expand load eval)
#:requires '#$(service-requirement service) (set! %load-path (cons #$modules %load-path))
#:respawn? '#$(service-respawn? service) (set! %load-compiled-path
#:start #$(service-start service) (cons #$compiled %load-compiled-path)))
#:stop #$(service-stop service)))
services))
;; guix-daemon 0.6 aborts if 'PATH' is undefined, so work around it. (use-modules (ice-9 ftw)
(setenv "PATH" "/run/current-system/bin") (guix build syscalls))
(format #t "starting services...~%") (register-services
(for-each start '#$(append-map service-provision services)))) #$@(map (lambda (service)
#~(make <service>
#:docstring '#$(service-documentation service)
#:provides '#$(service-provision service)
#:requires '#$(service-requirement service)
#:respawn? '#$(service-respawn? service)
#:start #$(service-start service)
#:stop #$(service-stop service)))
services))
(gexp->file "dmd.conf" config)) ;; guix-daemon 0.6 aborts if 'PATH' is undefined, so work around it.
(setenv "PATH" "/run/current-system/bin")
(format #t "starting services...~%")
(for-each start '#$(append-map service-provision services))))
(gexp->file "dmd.conf" config)))
;;; dmd.scm ends here ;;; dmd.scm ends here