services: rottlog: Add Rottlog to the global profile.
[jackhill/guix/guix.git] / gnu / services / xorg.scm
index a93dbfe..d098d83 100644 (file)
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 Sou Bunnbu <iyzsong@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -26,7 +26,7 @@
   #:use-module (gnu packages guile)
   #:use-module (gnu packages xorg)
   #:use-module (gnu packages gl)
-  #:use-module (gnu packages slim)
+  #:use-module (gnu packages display-managers)
   #:use-module (gnu packages gnustep)
   #:use-module (gnu packages admin)
   #:use-module (gnu packages bash)
   #:use-module (srfi srfi-26)
   #:use-module (ice-9 match)
   #:export (xorg-configuration-file
+            %default-xorg-modules
             xorg-start-command
+            xinitrc
+
             %default-slim-theme
             %default-slim-theme-name
             slim-configuration
             slim-service-type
             slim-service
 
+            screen-locker
+            screen-locker?
             screen-locker-service-type
             screen-locker-service))
 
@@ -137,9 +142,52 @@ EndSection
   "\n"
   extra-config))
 
+(define %default-xorg-modules
+  (list xf86-video-vesa
+        xf86-video-fbdev
+        xf86-video-modesetting
+        xf86-video-cirrus
+        xf86-video-intel
+        xf86-video-mach64
+        xf86-video-nouveau
+        xf86-video-nv
+        xf86-video-sis
+        xf86-input-libinput
+        xf86-input-evdev
+        xf86-input-keyboard
+        xf86-input-mouse
+        xf86-input-synaptics))
+
+(define (xorg-configuration-directory modules)
+  "Return a directory that contains the @code{.conf} files for X.org that
+includes the @code{share/X11/xorg.conf.d} directories of each package listed
+in @var{modules}."
+  (with-imported-modules '((guix build utils))
+    (computed-file "xorg.conf.d"
+                   #~(begin
+                       (use-modules (guix build utils)
+                                    (srfi srfi-1))
+
+                       (define files
+                         (append-map (lambda (module)
+                                       (find-files (string-append
+                                                    module
+                                                    "/share/X11/xorg.conf.d")
+                                                   "\\.conf$"))
+                                     (list #$@modules)))
+
+                       (mkdir #$output)
+                       (for-each (lambda (file)
+                                   (symlink file
+                                            (string-append #$output "/"
+                                                           (basename file))))
+                                 files)
+                       #t))))
+
 (define* (xorg-start-command #:key
                              (guile (canonical-package guile-2.0))
                              (configuration-file (xorg-configuration-file))
+                             (modules %default-xorg-modules)
                              (xorg-server xorg-server))
   "Return a derivation that builds a @var{guile} script to start the X server
 from @var{xorg-server}.  @var{configuration-file} is the server configuration
@@ -158,6 +206,7 @@ Usually the X server is started by a login manager."
                "-logverbose" "-verbose"
                "-xkbdir" (string-append #$xkeyboard-config "/share/X11/xkb")
                "-config" #$configuration-file
+               "-configdir" #$(xorg-configuration-directory modules)
                "-nolisten" "tcp" "-terminate"
 
                ;; Note: SLiM and other display managers add the
@@ -201,13 +250,14 @@ which should be passed to this script as the first argument.  If not, the
         (let* ((home          (getenv "HOME"))
                (xsession-file (string-append home "/.xsession"))
                (session       (match (command-line)
-                                ((_ x) x)
-                                (_     #$fallback-session))))
+                                ((_)       (list #$fallback-session))
+                                ((_ x ..1) x))))
           (if (file-exists? xsession-file)
               ;; Run ~/.xsession when it exists.
-              (exec-from-login-shell xsession-file session)
+              (apply exec-from-login-shell xsession-file session)
               ;; Otherwise, start the specified session.
-              (exec-from-login-shell session)))))
+              (apply exec-from-login-shell session)))))
+
   (program-file "xinitrc" builder))
 
 \f
@@ -217,7 +267,7 @@ which should be passed to this script as the first argument.  If not, the
 
 (define %default-slim-theme
   ;; Theme based on work by Felipe López.
-  #~(string-append #$%artwork-repository "/slim"))
+  (file-append %artwork-repository "/slim"))
 
 (define %default-slim-theme-name
   ;; This must be the name of the sub-directory in %DEFAULT-SLIM-THEME that
@@ -324,8 +374,8 @@ reboot_cmd " shepherd "/sbin/reboot\n"
                        (theme %default-slim-theme)
                        (theme-name %default-slim-theme-name)
                        (xauth xauth) (shepherd shepherd) (bash bash)
-                       (auto-login-session #~(string-append #$windowmaker
-                                                            "/bin/wmaker"))
+                       (auto-login-session (file-append windowmaker
+                                                        "/bin/wmaker"))
                        (startx (xorg-start-command)))
   "Return a service that spawns the SLiM graphical login manager, which in
 turn starts the X display server with @var{startx}, a command as returned by
@@ -400,14 +450,13 @@ command is @var{program}, to the set of setuid programs and add a PAM entry
 for it.  For example:
 
 @lisp
-(screen-locker-service xlockmore \"xlock\")
+ (screen-locker-service xlockmore \"xlock\")
 @end lisp
 
 makes the good ol' XlockMore usable."
   (service screen-locker-service-type
            (screen-locker program
-                          #~(string-append #$package
-                                           #$(string-append "/bin/" program))
+                          (file-append package "/bin/" program)
                           allow-empty-passwords?)))
 
 ;;; xorg.scm ends here