guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/02: services: Group desktop services in (gnu services desktop).


From: Ludovic Courtès
Subject: 01/02: services: Group desktop services in (gnu services desktop).
Date: Tue, 05 May 2015 20:44:37 +0000

civodul pushed a commit to branch master
in repository guix.

commit fe1a39d319258c26fb9bcedc2fd337a9e2f40df9
Author: Ludovic Courtès <address@hidden>
Date:   Fri May 1 19:36:10 2015 +0200

    services: Group desktop services in (gnu services desktop).
    
    * gnu/services/colord.scm, gnu/services/dbus.scm,
      gnu/services/upower.scm: Remove.
    * gnu/services/desktop.scm: New file, with contents taken from the above
      files.
    * gnu-system.am (GNU_SYSTEM_MODULES): Adjust accordingly.
    * doc/guix.texi (Desktop Services): New section.
      (Various Services): Move colord-service and upower-service from
      here to "Desktop Services".
---
 doc/guix.texi            |   56 +++++++---
 gnu-system.am            |    4 +-
 gnu/services/colord.scm  |   72 ------------
 gnu/services/dbus.scm    |  127 ----------------------
 gnu/services/desktop.scm |  270 ++++++++++++++++++++++++++++++++++++++++++++++
 gnu/services/upower.scm  |  122 ---------------------
 6 files changed, 310 insertions(+), 341 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index d9db408..8241cb0 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4641,6 +4641,7 @@ declaration.
 * Base Services::               Essential system services.
 * Networking Services::         Network setup, SSH daemon, etc.
 * X Window::                    Graphical display.
+* Desktop Services::            D-Bus and desktop services.
 * Various Services::            Other services.
 @end menu
 
@@ -4985,27 +4986,29 @@ appropriate screen resolution; otherwise, it must be a 
list of
 resolutions---e.g., @code{((1024 768) (640 480))}.
 @end deffn
 
address@hidden Various Services
address@hidden Various Services
address@hidden Desktop Services
address@hidden Desktop Services
 
-The @code{(gnu services lirc)} module provides the following service.
+The @code{(gnu services desktop)} module provides services that are
+usually useful in the context of a ``desktop'' setup---that is, on a
+machine running a graphical display server, possibly with graphical user
+interfaces, etc.
 
address@hidden {Monadic Procedure} lirc-service [#:lirc lirc] @
-       [#:device #f] [#:driver #f] [#:config-file #f] @
-       [#:extra-options '()]
-Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
-decodes infrared signals from remote controls.
address@hidden {Monadic Procedure} dbus-service @var{services} @
+                         [#:dbus @var{dbus}]
+Return a service that runs the ``system bus'', using @var{dbus}, with
+support for @var{services}.
 
-Optionally, @var{device}, @var{driver} and @var{config-file}
-(configuration file name) may be specified.  See @command{lircd} manual
-for details.
address@hidden://dbus.freedesktop.org/, D-Bus} is an inter-process communication
+facility.  Its system bus is used to allow system services to communicate
+and be notified of system-wide events.
 
-Finally, @var{extra-options} is a list of additional command-line options
-passed to @command{lircd}.
address@hidden must be a list of packages that provide an
address@hidden/dbus-1/system.d} directory containing additional D-Bus 
configuration
+and policy files.  For example, to allow avahi-daemon to use the system bus,
address@hidden must be equal to @code{(list avahi)}.
 @end deffn
 
address@hidden(gnu services upower)} provides a power-management daemon:
-
 @deffn {Monadic Procedure} upower-service [#:upower @var{upower}] @
                          [#:watts-up-pro? #f] @
                          [#:poll-batteries? #t] @
@@ -5025,8 +5028,6 @@ levels, with the given configuration settings.  It 
implements the
 GNOME.
 @end deffn
 
address@hidden(gnu services colord)} provides a color management service:
-
 @deffn {Monadic Procedure} colord-service [#:colord @var{colord}]
 Return a service that runs @command{colord}, a system service with a D-Bus
 interface to manage the color profiles of input and output devices such as
@@ -5035,6 +5036,27 @@ tool.  See 
@uref{http://www.freedesktop.org/software/colord/, the colord web
 site} for more information.
 @end deffn
 
+
address@hidden Various Services
address@hidden Various Services
+
+The @code{(gnu services lirc)} module provides the following service.
+
address@hidden {Monadic Procedure} lirc-service [#:lirc lirc] @
+       [#:device #f] [#:driver #f] [#:config-file #f] @
+       [#:extra-options '()]
+Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
+decodes infrared signals from remote controls.
+
+Optionally, @var{device}, @var{driver} and @var{config-file}
+(configuration file name) may be specified.  See @command{lircd} manual
+for details.
+
+Finally, @var{extra-options} is a list of additional command-line options
+passed to @command{lircd}.
address@hidden deffn
+
+
 @node Setuid Programs
 @subsection Setuid Programs
 
diff --git a/gnu-system.am b/gnu-system.am
index 798188f..9ffb76e 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -329,13 +329,11 @@ GNU_SYSTEM_MODULES =                              \
   gnu/services.scm                             \
   gnu/services/avahi.scm                       \
   gnu/services/base.scm                                \
-  gnu/services/colord.scm                      \
-  gnu/services/dbus.scm                                \
+  gnu/services/desktop.scm                     \
   gnu/services/dmd.scm                         \
   gnu/services/lirc.scm                                \
   gnu/services/networking.scm                  \
   gnu/services/ssh.scm                         \
-  gnu/services/upower.scm                      \
   gnu/services/xorg.scm                                \
                                                \
   gnu/system.scm                               \
diff --git a/gnu/services/colord.scm b/gnu/services/colord.scm
deleted file mode 100644
index 5884360..0000000
--- a/gnu/services/colord.scm
+++ /dev/null
@@ -1,72 +0,0 @@
-;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015 Ludovic Courtès <address@hidden>
-;;; Copyright © 2015 Andy Wingo <address@hidden>
-;;;
-;;; This file is part of GNU Guix.
-;;;
-;;; GNU Guix is free software; you can redistribute it and/or modify it
-;;; under the terms of the GNU General Public License as published by
-;;; the Free Software Foundation; either version 3 of the License, or (at
-;;; your option) any later version.
-;;;
-;;; GNU Guix is distributed in the hope that it will be useful, but
-;;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;;; GNU General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License
-;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
-
-(define-module (gnu services colord)
-  #:use-module (gnu services)
-  #:use-module (gnu system shadow)
-  #:use-module (gnu packages gnome)
-  #:use-module (ice-9 match)
-  #:use-module (guix monads)
-  #:use-module (guix store)
-  #:use-module (guix gexp)
-  #:export (colord-service))
-
-;;; Commentary:
-;;;
-;;; This module provides service definitions for the colord color management
-;;; service.
-;;;
-;;; Code:
-
-(define* (colord-service #:key (colord colord))
-  "Return a service that runs @command{colord}, a system service with a D-Bus
-interface to manage the color profiles of input and output devices such as
-screens and scanners.  It is notably used by the GNOME Color Manager graphical
-tool.  See @uref{http://www.freedesktop.org/software/colord/, the colord web
-site} for more information."
-  (with-monad %store-monad
-    (return
-     (service
-      (documentation "Run the colord color management service.")
-      (provision '(colord-daemon))
-      (requirement '(dbus-system udev))
-
-      (start #~(make-forkexec-constructor
-                (list (string-append #$colord "/libexec/colord"))))
-      (stop #~(make-kill-destructor))
-      (activate #~(begin
-                    (use-modules (guix build utils))
-                    (mkdir-p "/var/lib/colord")
-                    (let ((user (getpwnam "colord")))
-                      (chown "/var/lib/colord"
-                             (passwd:uid user) (passwd:gid user)))))
-
-      (user-groups (list (user-group
-                          (name "colord")
-                          (system? #t))))
-      (user-accounts (list (user-account
-                            (name "colord")
-                            (group "colord")
-                            (system? #t)
-                            (comment "colord daemon user")
-                            (home-directory "/var/empty")
-                            (shell
-                             "/run/current-system/profile/sbin/nologin"))))))))
-
-;;; colord.scm ends here
diff --git a/gnu/services/dbus.scm b/gnu/services/dbus.scm
deleted file mode 100644
index 8f3b350..0000000
--- a/gnu/services/dbus.scm
+++ /dev/null
@@ -1,127 +0,0 @@
-;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014, 2015 Ludovic Courtès <address@hidden>
-;;;
-;;; This file is part of GNU Guix.
-;;;
-;;; GNU Guix is free software; you can redistribute it and/or modify it
-;;; under the terms of the GNU General Public License as published by
-;;; the Free Software Foundation; either version 3 of the License, or (at
-;;; your option) any later version.
-;;;
-;;; GNU Guix is distributed in the hope that it will be useful, but
-;;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;;; GNU General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License
-;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
-
-(define-module (gnu services dbus)
-  #:use-module (gnu services)
-  #:use-module (gnu system shadow)
-  #:use-module (gnu packages glib)
-  #:use-module (gnu packages admin)
-  #:use-module (guix monads)
-  #:use-module (guix store)
-  #:use-module (guix gexp)
-  #:export (dbus-service))
-
-;;; Commentary:
-;;;
-;;; This module supports the configuration of the D-Bus message bus
-;;; (http://dbus.freedesktop.org/).  D-Bus is an inter-process communication
-;;; facility.  Its "system bus" is used to allow system services to
-;;; communicate and be notified of system-wide events.
-;;;
-;;; Code:
-
-(define (dbus-configuration-directory dbus services)
-  "Return a configuration directory for @var{dbus} that includes the
address@hidden/dbus-1/system.d} directories of each package listed in
address@hidden"
-  (define build
-    #~(begin
-        (use-modules (sxml simple)
-                     (srfi srfi-1))
-
-        (define (services->sxml services)
-          ;; Return the SXML 'includedir' clauses for DIRS.
-          `(busconfig
-            ,@(append-map (lambda (dir)
-                            `((includedir
-                               ,(string-append dir "/etc/dbus-1/system.d"))
-                              (servicedir         ;for '.service' files
-                               ,(string-append dir "/share/dbus-1/services"))))
-                          services)))
-
-        (mkdir #$output)
-        (copy-file (string-append #$dbus "/etc/dbus-1/system.conf")
-                   (string-append #$output "/system.conf"))
-
-        ;; The default 'system.conf' has an <includedir> clause for
-        ;; 'system.d', so create it.
-        (mkdir (string-append #$output "/system.d"))
-
-        ;; 'system-local.conf' is automatically included by the default
-        ;; 'system.conf', so this is where we stuff our own things.
-        (call-with-output-file (string-append #$output "/system-local.conf")
-          (lambda (port)
-            (sxml->xml (services->sxml (list address@hidden))
-                       port)))))
-
-  (gexp->derivation "dbus-configuration" build))
-
-(define* (dbus-service services #:key (dbus dbus))
-  "Return a service that runs the system bus, using @var{dbus}, with support
-for @var{services}.
-
address@hidden must be a list of packages that provide an
address@hidden/dbus-1/system.d} directory containing additional D-Bus 
configuration
-and policy files.  For example, to allow avahi-daemon to use the system bus,
address@hidden must be equal to @code{(list avahi)}."
-  (mlet %store-monad ((conf (dbus-configuration-directory dbus services)))
-    (return
-     (service
-      (documentation "Run the D-Bus system daemon.")
-      (provision '(dbus-system))
-      (requirement '(user-processes))
-      (start #~(make-forkexec-constructor
-                (list (string-append #$dbus "/bin/dbus-daemon")
-                      "--nofork"
-                      (string-append "--config-file=" #$conf "/system.conf"))))
-      (stop #~(make-kill-destructor))
-      (user-groups (list (user-group
-                          (name "messagebus")
-                          (system? #t))))
-      (user-accounts (list (user-account
-                            (name "messagebus")
-                            (group "messagebus")
-                            (system? #t)
-                            (comment "D-Bus system bus user")
-                            (home-directory "/var/run/dbus")
-                            (shell
-                             #~(string-append #$shadow "/sbin/nologin")))))
-      (activate #~(begin
-                    (use-modules (guix build utils))
-
-                    (mkdir-p "/var/run/dbus")
-
-                    (let ((user (getpwnam "messagebus")))
-                      (chown "/var/run/dbus"
-                             (passwd:uid user) (passwd:gid user)))
-
-                    (unless (file-exists? "/etc/machine-id")
-                      (format #t "creating /etc/machine-id...~%")
-                      (let ((prog (string-append #$dbus "/bin/dbus-uuidgen")))
-                        ;; XXX: We can't use 'system' because the initrd's
-                        ;; guile system(3) only works when 'sh' is in $PATH.
-                        (let ((pid (primitive-fork)))
-                          (if (zero? pid)
-                              (call-with-output-file "/etc/machine-id"
-                                (lambda (port)
-                                  (close-fdes 1)
-                                  (dup2 (port->fdes port) 1)
-                                  (execl prog)))
-                              (waitpid pid)))))))))))
-
-;;; dbus.scm ends here
diff --git a/gnu/services/desktop.scm b/gnu/services/desktop.scm
new file mode 100644
index 0000000..5945f7a
--- /dev/null
+++ b/gnu/services/desktop.scm
@@ -0,0 +1,270 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2014, 2015 Ludovic Courtès <address@hidden>
+;;; Copyright © 2015 Andy Wingo <address@hidden>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu services desktop)
+  #:use-module (gnu services)
+  #:use-module (gnu system shadow)
+  #:use-module (gnu packages glib)
+  #:use-module (gnu packages admin)
+  #:use-module (gnu packages gnome)
+  #:use-module (guix monads)
+  #:use-module (guix store)
+  #:use-module (guix gexp)
+  #:use-module (ice-9 match)
+  #:export (dbus-service
+            upower-service
+            colord-service))
+
+;;; Commentary:
+;;;
+;;; This module contains service definitions for a "desktop" environment.
+;;;
+;;; Code:
+
+
+;;;
+;;; D-Bus.
+;;;
+
+(define (dbus-configuration-directory dbus services)
+  "Return a configuration directory for @var{dbus} that includes the
address@hidden/dbus-1/system.d} directories of each package listed in
address@hidden"
+  (define build
+    #~(begin
+        (use-modules (sxml simple)
+                     (srfi srfi-1))
+
+        (define (services->sxml services)
+          ;; Return the SXML 'includedir' clauses for DIRS.
+          `(busconfig
+            ,@(append-map (lambda (dir)
+                            `((includedir
+                               ,(string-append dir "/etc/dbus-1/system.d"))
+                              (servicedir         ;for '.service' files
+                               ,(string-append dir "/share/dbus-1/services"))))
+                          services)))
+
+        (mkdir #$output)
+        (copy-file (string-append #$dbus "/etc/dbus-1/system.conf")
+                   (string-append #$output "/system.conf"))
+
+        ;; The default 'system.conf' has an <includedir> clause for
+        ;; 'system.d', so create it.
+        (mkdir (string-append #$output "/system.d"))
+
+        ;; 'system-local.conf' is automatically included by the default
+        ;; 'system.conf', so this is where we stuff our own things.
+        (call-with-output-file (string-append #$output "/system-local.conf")
+          (lambda (port)
+            (sxml->xml (services->sxml (list address@hidden))
+                       port)))))
+
+  (gexp->derivation "dbus-configuration" build))
+
+(define* (dbus-service services #:key (dbus dbus))
+  "Return a service that runs the \"system bus\", using @var{dbus}, with
+support for @var{services}.
+
address@hidden://dbus.freedesktop.org/, D-Bus} is an inter-process communication
+facility.  Its system bus is used to allow system services to communicate and
+be notified of system-wide events.
+
address@hidden must be a list of packages that provide an
address@hidden/dbus-1/system.d} directory containing additional D-Bus 
configuration
+and policy files.  For example, to allow avahi-daemon to use the system bus,
address@hidden must be equal to @code{(list avahi)}."
+  (mlet %store-monad ((conf (dbus-configuration-directory dbus services)))
+    (return
+     (service
+      (documentation "Run the D-Bus system daemon.")
+      (provision '(dbus-system))
+      (requirement '(user-processes))
+      (start #~(make-forkexec-constructor
+                (list (string-append #$dbus "/bin/dbus-daemon")
+                      "--nofork"
+                      (string-append "--config-file=" #$conf "/system.conf"))))
+      (stop #~(make-kill-destructor))
+      (user-groups (list (user-group
+                          (name "messagebus")
+                          (system? #t))))
+      (user-accounts (list (user-account
+                            (name "messagebus")
+                            (group "messagebus")
+                            (system? #t)
+                            (comment "D-Bus system bus user")
+                            (home-directory "/var/run/dbus")
+                            (shell
+                             #~(string-append #$shadow "/sbin/nologin")))))
+      (activate #~(begin
+                    (use-modules (guix build utils))
+
+                    (mkdir-p "/var/run/dbus")
+
+                    (let ((user (getpwnam "messagebus")))
+                      (chown "/var/run/dbus"
+                             (passwd:uid user) (passwd:gid user)))
+
+                    (unless (file-exists? "/etc/machine-id")
+                      (format #t "creating /etc/machine-id...~%")
+                      (let ((prog (string-append #$dbus "/bin/dbus-uuidgen")))
+                        ;; XXX: We can't use 'system' because the initrd's
+                        ;; guile system(3) only works when 'sh' is in $PATH.
+                        (let ((pid (primitive-fork)))
+                          (if (zero? pid)
+                              (call-with-output-file "/etc/machine-id"
+                                (lambda (port)
+                                  (close-fdes 1)
+                                  (dup2 (port->fdes port) 1)
+                                  (execl prog)))
+                              (waitpid pid)))))))))))
+
+
+;;;
+;;; Upower D-Bus service.
+;;;
+
+(define* (upower-configuration-file #:key watts-up-pro? poll-batteries?
+                                    ignore-lid? use-percentage-for-policy?
+                                    percentage-low percentage-critical
+                                    percentage-action time-low
+                                    time-critical time-action
+                                    critical-power-action)
+  "Return an upower-daemon configuration file."
+  (define (bool value)
+    (if value "true\n" "false\n"))
+
+  (text-file "UPower.conf"
+             (string-append
+              "[UPower]\n"
+              "EnableWattsUpPro=" (bool watts-up-pro?)
+              "NoPollBatteries=" (bool (not poll-batteries?))
+              "IgnoreLid=" (bool ignore-lid?)
+              "UsePercentageForPolicy=" (bool use-percentage-for-policy?)
+              "PercentageLow=" (number->string percentage-low) "\n"
+              "PercentageCritical=" (number->string percentage-critical) "\n"
+              "PercentageAction=" (number->string percentage-action) "\n"
+              "TimeLow=" (number->string time-low) "\n"
+              "TimeCritical=" (number->string time-critical) "\n"
+              "TimeAction=" (number->string time-action) "\n"
+              "CriticalPowerAction=" (match critical-power-action
+                                       ('hybrid-sleep "HybridSleep")
+                                       ('hibernate "Hibernate")
+                                       ('power-off "PowerOff"))
+              "\n")))
+
+(define* (upower-service #:key (upower upower)
+                         (watts-up-pro? #f)
+                         (poll-batteries? #t)
+                         (ignore-lid? #f)
+                         (use-percentage-for-policy? #f)
+                         (percentage-low 10)
+                         (percentage-critical 3)
+                         (percentage-action 2)
+                         (time-low 1200)
+                         (time-critical 300)
+                         (time-action 120)
+                         (critical-power-action 'hybrid-sleep))
+  "Return a service that runs @uref{http://upower.freedesktop.org/,
address@hidden, a system-wide monitor for power consumption and battery
+levels, with the given configuration settings.  It implements the
address@hidden D-Bus interface, and is notably used by GNOME."
+  (mlet %store-monad ((config (upower-configuration-file
+                               #:watts-up-pro? watts-up-pro?
+                               #:poll-batteries? poll-batteries?
+                               #:ignore-lid? ignore-lid?
+                               #:use-percentage-for-policy? 
use-percentage-for-policy?
+                               #:percentage-low percentage-low
+                               #:percentage-critical percentage-critical
+                               #:percentage-action percentage-action
+                               #:time-low time-low
+                               #:time-critical time-critical
+                               #:time-action time-action
+                               #:critical-power-action critical-power-action)))
+    (return
+     (service
+      (documentation "Run the UPower power and battery monitor.")
+      (provision '(upower-daemon))
+      (requirement '(dbus-system udev))
+
+      (start #~(make-forkexec-constructor
+                (list (string-append #$upower "/libexec/upowerd"))
+                #:environment-variables
+                (list (string-append "UPOWER_CONF_FILE_NAME=" #$config))))
+      (stop #~(make-kill-destructor))
+      (activate #~(begin
+                    (use-modules (guix build utils))
+                    (mkdir-p "/var/lib/upower")
+                    (let ((user (getpwnam "upower")))
+                      (chown "/var/lib/upower"
+                             (passwd:uid user) (passwd:gid user)))))
+
+      (user-groups (list (user-group
+                          (name "upower")
+                          (system? #t))))
+      (user-accounts (list (user-account
+                            (name "upower")
+                            (group "upower")
+                            (system? #t)
+                            (comment "UPower daemon user")
+                            (home-directory "/var/empty")
+                            (shell
+                             #~(string-append #$shadow "/sbin/nologin")))))))))
+
+
+;;;
+;;; Colord D-Bus service.
+;;;
+
+(define* (colord-service #:key (colord colord))
+  "Return a service that runs @command{colord}, a system service with a D-Bus
+interface to manage the color profiles of input and output devices such as
+screens and scanners.  It is notably used by the GNOME Color Manager graphical
+tool.  See @uref{http://www.freedesktop.org/software/colord/, the colord web
+site} for more information."
+  (with-monad %store-monad
+    (return
+     (service
+      (documentation "Run the colord color management service.")
+      (provision '(colord-daemon))
+      (requirement '(dbus-system udev))
+
+      (start #~(make-forkexec-constructor
+                (list (string-append #$colord "/libexec/colord"))))
+      (stop #~(make-kill-destructor))
+      (activate #~(begin
+                    (use-modules (guix build utils))
+                    (mkdir-p "/var/lib/colord")
+                    (let ((user (getpwnam "colord")))
+                      (chown "/var/lib/colord"
+                             (passwd:uid user) (passwd:gid user)))))
+
+      (user-groups (list (user-group
+                          (name "colord")
+                          (system? #t))))
+      (user-accounts (list (user-account
+                            (name "colord")
+                            (group "colord")
+                            (system? #t)
+                            (comment "colord daemon user")
+                            (home-directory "/var/empty")
+                            (shell
+                             #~(string-append #$shadow "/sbin/nologin")))))))))
+
+;;; desktop.scm ends here
diff --git a/gnu/services/upower.scm b/gnu/services/upower.scm
deleted file mode 100644
index 3654c81..0000000
--- a/gnu/services/upower.scm
+++ /dev/null
@@ -1,122 +0,0 @@
-;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015 Andy Wingo <address@hidden>
-;;;
-;;; This file is part of GNU Guix.
-;;;
-;;; GNU Guix is free software; you can redistribute it and/or modify it
-;;; under the terms of the GNU General Public License as published by
-;;; the Free Software Foundation; either version 3 of the License, or (at
-;;; your option) any later version.
-;;;
-;;; GNU Guix is distributed in the hope that it will be useful, but
-;;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;;; GNU General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License
-;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
-
-(define-module (gnu services upower)
-  #:use-module (gnu services)
-  #:use-module (gnu system shadow)
-  #:use-module (gnu packages gnome)
-  #:use-module (ice-9 match)
-  #:use-module (guix monads)
-  #:use-module (guix store)
-  #:use-module (guix gexp)
-  #:export (upower-service))
-
-;;; Commentary:
-;;;
-;;; This module provides service definitions for the UPower power and battery
-;;; monitoring service.
-;;;
-;;; Code:
-
-(define* (configuration-file #:key watts-up-pro? poll-batteries? ignore-lid?
-                             use-percentage-for-policy? percentage-low
-                             percentage-critical percentage-action
-                             time-low time-critical time-action
-                             critical-power-action)
-  "Return an upower-daemon configuration file."
-  (define (bool value)
-    (if value "true\n" "false\n"))
-
-  (text-file "UPower.conf"
-             (string-append
-              "[UPower]\n"
-              "EnableWattsUpPro=" (bool watts-up-pro?)
-              "NoPollBatteries=" (bool (not poll-batteries?))
-              "IgnoreLid=" (bool ignore-lid?)
-              "UsePercentageForPolicy=" (bool use-percentage-for-policy?)
-              "PercentageLow=" (number->string percentage-low) "\n"
-              "PercentageCritical=" (number->string percentage-critical) "\n"
-              "PercentageAction=" (number->string percentage-action) "\n"
-              "TimeLow=" (number->string time-low) "\n"
-              "TimeCritical=" (number->string time-critical) "\n"
-              "TimeAction=" (number->string time-action) "\n"
-              "CriticalPowerAction=" (match critical-power-action
-                                       ('hybrid-sleep "HybridSleep")
-                                       ('hibernate "Hibernate")
-                                       ('power-off "PowerOff"))
-              "\n")))
-
-(define* (upower-service #:key (upower upower)
-                         (watts-up-pro? #f)
-                         (poll-batteries? #t)
-                         (ignore-lid? #f)
-                         (use-percentage-for-policy? #f)
-                         (percentage-low 10)
-                         (percentage-critical 3)
-                         (percentage-action 2)
-                         (time-low 1200)
-                         (time-critical 300)
-                         (time-action 120)
-                         (critical-power-action 'hybrid-sleep))
-  "Return a service that runs @uref{http://upower.freedesktop.org/,
address@hidden, a system-wide monitor for power consumption and battery
-levels, with the given configuration settings.  It implements the
address@hidden D-Bus interface, and is notably used by GNOME."
-  (mlet %store-monad ((config (configuration-file
-                               #:watts-up-pro? watts-up-pro?
-                               #:poll-batteries? poll-batteries?
-                               #:ignore-lid? ignore-lid?
-                               #:use-percentage-for-policy? 
use-percentage-for-policy?
-                               #:percentage-low percentage-low
-                               #:percentage-critical percentage-critical
-                               #:percentage-action percentage-action
-                               #:time-low time-low
-                               #:time-critical time-critical
-                               #:time-action time-action
-                               #:critical-power-action critical-power-action)))
-    (return
-     (service
-      (documentation "Run the UPower power and battery monitor.")
-      (provision '(upower-daemon))
-      (requirement '(dbus-system udev))
-
-      (start #~(make-forkexec-constructor
-                (list (string-append #$upower "/libexec/upowerd"))
-                #:environment-variables
-                (list (string-append "UPOWER_CONF_FILE_NAME=" #$config))))
-      (stop #~(make-kill-destructor))
-      (activate #~(begin
-                    (use-modules (guix build utils))
-                    (mkdir-p "/var/lib/upower")
-                    (let ((user (getpwnam "upower")))
-                      (chown "/var/lib/upower"
-                             (passwd:uid user) (passwd:gid user)))))
-
-      (user-groups (list (user-group
-                          (name "upower")
-                          (system? #t))))
-      (user-accounts (list (user-account
-                            (name "upower")
-                            (group "upower")
-                            (system? #t)
-                            (comment "UPower daemon user")
-                            (home-directory "/var/empty")
-                            (shell
-                             "/run/current-system/profile/sbin/nologin"))))))))
-
-;;; upower.scm ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]