services: xorg: Rewrite using gexps.

* gnu/services/xorg.scm (xorg-start-command): Rewrite in terms of
  'gexp->script'.
  (xinitrc): Likewise.
This commit is contained in:
Ludovic Courtès 2014-04-27 19:28:47 +02:00
parent f6a7b21df7
commit 8779d34294
1 changed files with 24 additions and 59 deletions

View File

@ -87,77 +87,42 @@ Section \"Screen\"
Device \"Device-vesa\" Device \"Device-vesa\"
EndSection")) EndSection"))
(mlet %store-monad ((guile-bin (package-file guile "bin/guile")) (mlet %store-monad ((config (xserver.conf)))
(xorg-bin (package-file xorg-server "bin/X")) (define script
(dri (package-file mesa "lib/dri"))
(xkbcomp-bin (package-file xkbcomp "bin"))
(xkb-dir (package-file xkeyboard-config
"share/X11/xkb"))
(config (xserver.conf)))
(define builder
;; Write a small wrapper around the X server. ;; Write a small wrapper around the X server.
`(let ((out (assoc-ref %outputs "out"))) #~(begin
(call-with-output-file out (setenv "XORG_DRI_DRIVER_PATH" (string-append #$mesa "/lib/dri"))
(lambda (port) (setenv "XKB_BINDIR" (string-append #$xkbcomp "/bin"))
(format port "#!~a --no-auto-compile~%!#~%" ,guile-bin)
(write '(begin
(setenv "XORG_DRI_DRIVER_PATH" ,dri)
(setenv "XKB_BINDIR" ,xkbcomp-bin)
(apply execl (apply execl (string-append #$xorg-server "/bin/X")
"-ac" "-logverbose" "-verbose"
"-xkbdir" (string-append #$xkeyboard-config "/share/X11/xkb")
"-config" #$config
"-nolisten" "tcp" "-terminate"
,xorg-bin "-ac" "-logverbose" "-verbose" ;; Note: SLiM and other display managers add the
"-xkbdir" ,xkb-dir ;; '-auth' flag by themselves.
"-config" ,(derivation->output-path config) (cdr (command-line)))))
"-nolisten" "tcp" "-terminate"
;; Note: SLiM and other display managers add the (gexp->script "start-xorg" script)))
;; '-auth' flag by themselves.
(cdr (command-line))))
port)))
(chmod out #o555)
#t))
(mlet %store-monad ((inputs (lower-inputs
`(("xorg" ,xorg-server)
("xkbcomp" ,xkbcomp)
("xkeyboard-config" ,xkeyboard-config)
("mesa" ,mesa)
("guile" ,guile)
("xorg.conf" ,config)))))
(derivation-expression "start-xorg" builder
#:inputs inputs))))
(define* (xinitrc #:key (define* (xinitrc #:key
(guile guile-final) (guile guile-final)
(ratpoison ratpoison) (ratpoison ratpoison)
(windowmaker windowmaker)) (windowmaker windowmaker))
"Return a system-wide xinitrc script that starts the specified X session." "Return a system-wide xinitrc script that starts the specified X session."
(mlet %store-monad ((guile-bin (package-file guile "bin/guile")) (define builder
(ratpoison-bin (package-file ratpoison "bin/ratpoison")) #~(begin
(wmaker-bin (package-file windowmaker "bin/wmaker")) (use-modules (ice-9 match))
(inputs (lower-inputs
`(("raptoison" ,ratpoison)
("wmaker" ,windowmaker)))))
(define builder
`(let ((out (assoc-ref %outputs "out")))
(call-with-output-file out
(lambda (port)
(format port "#!~a --no-auto-compile~%!#~%" ,guile-bin)
(write '(begin
(use-modules (ice-9 match))
;; TODO: Check for ~/.xsession. ;; TODO: Check for ~/.xsession.
(match (command-line) (match (command-line)
((_ "ratpoison") ((_ "ratpoison")
(execl ,ratpoison-bin)) (execl (string-append #$ratpoison "/bin/ratpoison")))
(_ (_
(execl ,wmaker-bin)))) (execl (string-append #$windowmaker "/bin/wmaker"))))))
port)))
(chmod out #o555)
#t))
(derivation-expression "xinitrc" builder #:inputs inputs))) (gexp->script "xinitrc" builder))
(define* (slim-service #:key (slim slim) (define* (slim-service #:key (slim slim)
(allow-empty-passwords? #t) auto-login? (allow-empty-passwords? #t) auto-login?