unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Add upower
@ 2015-04-04 19:56 Andy Wingo
  2015-04-05 14:55 ` David Thompson
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andy Wingo @ 2015-04-04 19:56 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 237 bytes --]

Two patches attached.

Unfortunately to use this you need to expand out %base-services to add
upower to the udev-service form.  Also you need the upower-service,
obviously, and upower needs to be added to the dbus-service form as
well.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-Add-upower-package.patch --]
[-- Type: text/x-diff, Size: 5413 bytes --]

From 4725d267b7c18bc4ba4294f90336871311386bb2 Mon Sep 17 00:00:00 2001
From: Andy Wingo <wingo@pobox.com>
Date: Sat, 4 Apr 2015 21:48:01 +0200
Subject: [PATCH 2/3] Add upower package.

* gnu/packages/gnome.scm (upower): New variable.
* gnu/packages/patches/upower-builddir.patch: New patch.
---
 gnu/packages/gnome.scm                     | 53 ++++++++++++++++++++++++++++++
 gnu/packages/patches/upower-builddir.patch | 44 +++++++++++++++++++++++++
 2 files changed, 97 insertions(+)
 create mode 100644 gnu/packages/patches/upower-builddir.patch

diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index 445b4a1..8b0a055 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -43,6 +43,7 @@
   #:use-module (gnu packages gnutls)
   #:use-module (gnu packages iso-codes)
   #:use-module (gnu packages libcanberra)
+  #:use-module (gnu packages libusb)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages image)
   #:use-module (gnu packages perl)
@@ -1718,3 +1719,55 @@ your system.
 It supports several profiles, multiple tabs and implements several
 keyboard shortcuts.")
     (license license:gpl3+)))
+
+(define-public upower
+  (package
+    (name "upower")
+    (version "0.99.2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "http://upower.freedesktop.org/releases/"
+                           name "-" version ".tar.xz"))
+       (sha256
+        (base32
+         "0vwlh20jmaf01m38kfn8yx2869a3clmkzlycrj99rf4nvwx4bp79"))
+       (patches (list (search-patch "upower-builddir.patch")))))
+    (build-system glib-or-gtk-build-system)
+    (arguments
+     '(;; The tests want to contact the system bus, which can't be done in the
+       ;; build environment.  The integration test can run, but the last of
+       ;; the up-self-tests doesn't.  Disable tests for now.
+       #:tests? #f
+       #:configure-flags (list "--localstatedir=/var"
+                               (string-append "--with-udevrulesdir="
+                                              (assoc-ref %outputs "out")
+                                              "/lib/udev/rules.d"))
+       #:phases
+       (modify-phases %standard-phases
+         (add-before configure patch-/bin/true
+                     (lambda _
+                       (substitute* "configure"
+                         (("/bin/true") (which "true")))))
+         (add-before configure patch-integration-test
+                     (lambda _
+                       (substitute* "src/linux/integration-test"
+                         (("/usr/bin/python3") (which "python3"))))))))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)
+       ("intltool" ,intltool)
+       ("python" ,python)))
+    (inputs
+     `(("eudev" ,eudev)
+       ("dbus" ,dbus)
+       ("dbus-glib" ,dbus-glib)
+       ("libusb" ,libusb)
+       ))
+    (home-page "http://upower.freedesktop.org/")
+    (synopsis "System daemon for managing power devices")
+    (description
+     "UPower is an abstraction for enumerating power devices,
+listening to device events and querying history and statistics.  Any
+application or service on the system can access the org.freedesktop.UPower
+service via the system message bus.")
+    (license license:gpl2+)))
diff --git a/gnu/packages/patches/upower-builddir.patch b/gnu/packages/patches/upower-builddir.patch
new file mode 100644
index 0000000..13cef58
--- /dev/null
+++ b/gnu/packages/patches/upower-builddir.patch
@@ -0,0 +1,44 @@
+Remove explicit set of UPOWER_CONF_FILE_NAME in up-self-test.c;
+instead the harness should set it.  In Guix we set it explicitly; the
+right thing is to use AM_TEST_ENVIRONMENT and regenerate the
+makefiles, but we can't regenerate because current autotools carp on
+some things, so we patch the Makefile.in instead.
+
+Also fix to not try to create /var/lib/upower if /var isn't writable.
+
+Patch by Andy Wingo <wingo@igalia.com>
+
+--- upower-0.99.2.orig/src/Makefile.in	2014-12-18 10:32:01.000000000 +0100
++++ upower-0.99.2/src/Makefile.in	2015-04-04 19:49:28.020843678 +0200
+@@ -780,6 +780,7 @@
+ 
+ @UP_BUILD_TESTS_TRUE@up_self_test_CFLAGS = $(AM_CFLAGS) $(WARNINGFLAGS_C)
+ @UP_BUILD_TESTS_TRUE@TESTS_ENVIRONMENT = $(DBUS_LAUNCH)
++@UP_BUILD_TESTS_TRUE@AM_TESTS_ENVIRONMENT = UPOWER_CONF_FILE_NAME=$(top_srcdir)/etc/UPower.conf
+ dbusservicedir = $(datadir)/dbus-1/system-services
+ dbusservice_in_files = org.freedesktop.UPower.service.in
+ dbusservice_DATA = $(dbusservice_in_files:.service.in=.service)
+@@ -1789,7 +1790,7 @@
+ @HAVE_SYSTEMDSYSTEMUNITDIR_TRUE@	@sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
+ 
+ install-data-hook:
+-	if test -w $(DESTDIR)$(prefix)/; then \
++	if test -w $(DESTDIR)$(localstatedir)/; then \
+ 		mkdir -p $(DESTDIR)$(historydir); \
+ 	fi
+ 
+--- upower-0.99.2.orig/src/up-self-test.c	2014-07-17 09:46:15.000000000 +0200
++++ upower-0.99.2/src/up-self-test.c	2015-04-04 18:43:04.952741927 +0200
+@@ -295,12 +295,6 @@
+ #endif
+ 	g_test_init (&argc, &argv, NULL);
+ 
+-	/* make check, vs. make distcheck */
+-	if (g_file_test ("../etc/UPower.conf", G_FILE_TEST_EXISTS))
+-		g_setenv ("UPOWER_CONF_FILE_NAME", "../etc/UPower.conf", TRUE);
+-	else
+-		g_setenv ("UPOWER_CONF_FILE_NAME", "../../etc/UPower.conf", TRUE);
+-
+ 	/* tests go here */
+ 	g_test_add_func ("/power/backend", up_test_backend_func);
+ 	g_test_add_func ("/power/device", up_test_device_func);
-- 
2.2.1


[-- Attachment #3: 0003-Add-upower-service.patch --]
[-- Type: text/x-diff, Size: 6722 bytes --]

From ee0d6fa2b5951edca3c79e3046b42226aca0540a Mon Sep 17 00:00:00 2001
From: Andy Wingo <wingo@pobox.com>
Date: Sat, 4 Apr 2015 21:49:02 +0200
Subject: [PATCH 3/3] Add upower service.

* gnu-system.am (GNU_SYSTEM_MODULES): Add gnu/services/upower.scm.
* gnu/services/upower.scm: New file, defining a upower service.
---
 gnu-system.am           |   1 +
 gnu/services/upower.scm | 120 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 121 insertions(+)
 create mode 100644 gnu/services/upower.scm

diff --git a/gnu-system.am b/gnu-system.am
index 95c4eeb..a3638d7 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -330,6 +330,7 @@ GNU_SYSTEM_MODULES =				\
   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/upower.scm b/gnu/services/upower.scm
new file mode 100644
index 0000000..c2d3e55
--- /dev/null
+++ b/gnu/services/upower.scm
@@ -0,0 +1,120 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2015 Andy Wingo <wingo@igalia.com>
+;;;
+;;; 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)
+              "PercentageCritical=" (number->string percentage-critical)
+              "PercentageAction=" (number->string percentage-action)
+              "TimeLow=" (number->string time-low)
+              "TimeCritical=" (number->string time-critical)
+              "TimeAction=" (number->string time-action)
+              "CriticalPowerAction=" (match critical-power-action
+                                       ('hybrid-sleep "HybridSleep")
+                                       ('hibernate "Hibernate")
+                                       ('power-off "PowerOff")))))
+
+(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 @command{upowerd}, a system-wide
+monitor for power consumption and battery levels."
+  (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
-- 
2.2.1


[-- Attachment #4: Type: text/plain, Size: 26 bytes --]


-- 
http://wingolog.org/

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add upower
  2015-04-04 19:56 [PATCH] Add upower Andy Wingo
@ 2015-04-05 14:55 ` David Thompson
  2015-04-05 20:33   ` Making service values transparent Ludovic Courtès
  2015-04-12 21:01   ` [PATCH] Add upower Ludovic Courtès
  2015-04-05 15:07 ` Mark H Weaver
  2015-04-12 22:05 ` Ludovic Courtès
  2 siblings, 2 replies; 6+ messages in thread
From: David Thompson @ 2015-04-05 14:55 UTC (permalink / raw)
  To: Andy Wingo, guix-devel

Andy Wingo <wingo@pobox.com> writes:

> Two patches attached.
>
> Unfortunately to use this you need to expand out %base-services to add
> upower to the udev-service form.  Also you need the upower-service,
> obviously, and upower needs to be added to the dbus-service form as
> well.

This isn't the first time I've seen people expanding out %base-services,
and I was also planning to do so for my OS config.  I wonder if we
should create a 'make-base-services' procedure that accomodates the
common tweaks to the %base-services list: the MOTD, the list of packages
for dbus-service, etc.

Anyway, these patches are awesome to me!  Very minor nitpicks and a
style question below:

> From 4725d267b7c18bc4ba4294f90336871311386bb2 Mon Sep 17 00:00:00 2001
> From: Andy Wingo <wingo@pobox.com>
> Date: Sat, 4 Apr 2015 21:48:01 +0200
> Subject: [PATCH 2/3] Add upower package.
>
> * gnu/packages/gnome.scm (upower): New variable.
> * gnu/packages/patches/upower-builddir.patch: New patch.
> ---
>  gnu/packages/gnome.scm                     | 53 ++++++++++++++++++++++++++++++
>  gnu/packages/patches/upower-builddir.patch | 44 +++++++++++++++++++++++++
>  2 files changed, 97 insertions(+)
>  create mode 100644 gnu/packages/patches/upower-builddir.patch
>
> diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
> index 445b4a1..8b0a055 100644
> --- a/gnu/packages/gnome.scm
> +++ b/gnu/packages/gnome.scm
> @@ -43,6 +43,7 @@
>    #:use-module (gnu packages gnutls)
>    #:use-module (gnu packages iso-codes)
>    #:use-module (gnu packages libcanberra)
> +  #:use-module (gnu packages libusb)
>    #:use-module (gnu packages linux)
>    #:use-module (gnu packages image)
>    #:use-module (gnu packages perl)
> @@ -1718,3 +1719,55 @@ your system.
>  It supports several profiles, multiple tabs and implements several
>  keyboard shortcuts.")
>      (license license:gpl3+)))
> +
> +(define-public upower
> +  (package
> +    (name "upower")
> +    (version "0.99.2")
> +    (source
> +     (origin
> +       (method url-fetch)
> +       (uri (string-append "http://upower.freedesktop.org/releases/"
> +                           name "-" version ".tar.xz"))
> +       (sha256
> +        (base32
> +         "0vwlh20jmaf01m38kfn8yx2869a3clmkzlycrj99rf4nvwx4bp79"))
> +       (patches (list (search-patch "upower-builddir.patch")))))

Could you add a comment about the upstream status of this patch, perhaps
with a URL pointing to the relevant bug tracker, if applicable?

> +    (build-system glib-or-gtk-build-system)
> +    (arguments
> +     '(;; The tests want to contact the system bus, which can't be done in the
> +       ;; build environment.  The integration test can run, but the last of
> +       ;; the up-self-tests doesn't.  Disable tests for now.
> +       #:tests? #f
> +       #:configure-flags (list "--localstatedir=/var"
> +                               (string-append "--with-udevrulesdir="
> +                                              (assoc-ref %outputs "out")
> +                                              "/lib/udev/rules.d"))
> +       #:phases
> +       (modify-phases %standard-phases
> +         (add-before configure patch-/bin/true
> +                     (lambda _
> +                       (substitute* "configure"
> +                         (("/bin/true") (which "true")))))
> +         (add-before configure patch-integration-test
> +                     (lambda _
> +                       (substitute* "src/linux/integration-test"
> +                         (("/usr/bin/python3") (which "python3"))))))))
> +    (native-inputs
> +     `(("pkg-config" ,pkg-config)
> +       ("intltool" ,intltool)
> +       ("python" ,python)))
> +    (inputs
> +     `(("eudev" ,eudev)
> +       ("dbus" ,dbus)
> +       ("dbus-glib" ,dbus-glib)
> +       ("libusb" ,libusb)
> +       ))

Reunite with the parens on the previous line for maximum happiness. :)

> +    (home-page "http://upower.freedesktop.org/")
> +    (synopsis "System daemon for managing power devices")
> +    (description
> +     "UPower is an abstraction for enumerating power devices,
> +listening to device events and querying history and statistics.  Any
> +application or service on the system can access the org.freedesktop.UPower
> +service via the system message bus.")
> +    (license license:gpl2+)))

[...]

>
> From ee0d6fa2b5951edca3c79e3046b42226aca0540a Mon Sep 17 00:00:00 2001
> From: Andy Wingo <wingo@pobox.com>
> Date: Sat, 4 Apr 2015 21:49:02 +0200
> Subject: [PATCH 3/3] Add upower service.
>
> * gnu-system.am (GNU_SYSTEM_MODULES): Add gnu/services/upower.scm.
> * gnu/services/upower.scm: New file, defining a upower service.
> ---
>  gnu-system.am           |   1 +
>  gnu/services/upower.scm | 120 ++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 121 insertions(+)
>  create mode 100644 gnu/services/upower.scm
>
> diff --git a/gnu-system.am b/gnu-system.am
> index 95c4eeb..a3638d7 100644
> --- a/gnu-system.am
> +++ b/gnu-system.am
> @@ -330,6 +330,7 @@ GNU_SYSTEM_MODULES =				\
>    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/upower.scm b/gnu/services/upower.scm
> new file mode 100644
> index 0000000..c2d3e55
> --- /dev/null
> +++ b/gnu/services/upower.scm
> @@ -0,0 +1,120 @@
> +;;; GNU Guix --- Functional package management for GNU
> +;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org>
> +;;; Copyright © 2015 Andy Wingo <wingo@igalia.com>
> +;;;
> +;;; 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)
> +              "PercentageCritical=" (number->string percentage-critical)
> +              "PercentageAction=" (number->string percentage-action)
> +              "TimeLow=" (number->string time-low)
> +              "TimeCritical=" (number->string time-critical)
> +              "TimeAction=" (number->string time-action)
> +              "CriticalPowerAction=" (match critical-power-action
> +                                       ('hybrid-sleep "HybridSleep")
> +                                       ('hibernate "Hibernate")
> +                                       ('power-off "PowerOff")))))

I didn't realize that key/value pairs like this could all be stuffed
onto one line in a conf file.  Would it make sense to add newlines
anyway, for people that might be inspecting their system and come across
this file?

> +
> +(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 @command{upowerd}, a system-wide
> +monitor for power consumption and battery levels."
> +  (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
> -- 
> 2.2.1

Thanks!

-- 
David Thompson
Web Developer - Free Software Foundation - http://fsf.org
GPG Key: 0FF1D807
Support the FSF: https://fsf.org/donate

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add upower
  2015-04-04 19:56 [PATCH] Add upower Andy Wingo
  2015-04-05 14:55 ` David Thompson
@ 2015-04-05 15:07 ` Mark H Weaver
  2015-04-12 22:05 ` Ludovic Courtès
  2 siblings, 0 replies; 6+ messages in thread
From: Mark H Weaver @ 2015-04-05 15:07 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guix-devel

Hi Andy!

Here are some more comments to add to David's:

Andy Wingo <wingo@pobox.com> writes:

> From 4725d267b7c18bc4ba4294f90336871311386bb2 Mon Sep 17 00:00:00 2001
> From: Andy Wingo <wingo@pobox.com>
> Date: Sat, 4 Apr 2015 21:48:01 +0200
> Subject: [PATCH 2/3] Add upower package.

By our conventions, we write this first line as: "gnu: Add upower."

> * gnu/packages/gnome.scm (upower): New variable.
> * gnu/packages/patches/upower-builddir.patch: New patch.

The patch also needs to be added to 'dist_patch_DATA' in gnu-system.am.

David Thompson <dthompson2@worcester.edu> wrote:
> Could you add a comment about the upstream status of this patch, perhaps
> with a URL pointing to the relevant bug tracker, if applicable?

Agreed, but I think this should go in the top of the patch file rather
than in the package definition itself.

      Thanks!
        Mark

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Making service values transparent
  2015-04-05 14:55 ` David Thompson
@ 2015-04-05 20:33   ` Ludovic Courtès
  2015-04-12 21:01   ` [PATCH] Add upower Ludovic Courtès
  1 sibling, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2015-04-05 20:33 UTC (permalink / raw)
  To: David Thompson; +Cc: Andy Wingo, guix-devel

David Thompson <dthompson2@worcester.edu> skribis:

> Andy Wingo <wingo@pobox.com> writes:
>
>> Two patches attached.
>>
>> Unfortunately to use this you need to expand out %base-services to add
>> upower to the udev-service form.  Also you need the upower-service,
>> obviously, and upower needs to be added to the dbus-service form as
>> well.
>
> This isn't the first time I've seen people expanding out %base-services,
> and I was also planning to do so for my OS config.  I wonder if we
> should create a 'make-base-services' procedure that accomodates the
> common tweaks to the %base-services list: the MOTD, the list of packages
> for dbus-service, etc.

This must be fixed, basically by making the return value of the
foo-service procedures transparent and amenable to customization,
filtering, etc.

Now that we have extensible gexps, I think we may be able to
“demonadify” those service procedures, by adding declarative forms
corresponding to ‘text-file*’ and co. (just like ‘local-file’ is the
declarative equivalent of the ‘interned-file’ procedure.)

I’m not yet sure this is the right thing, but it’s appealing.

Thoughts?

Ludo’.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add upower
  2015-04-05 14:55 ` David Thompson
  2015-04-05 20:33   ` Making service values transparent Ludovic Courtès
@ 2015-04-12 21:01   ` Ludovic Courtès
  1 sibling, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2015-04-12 21:01 UTC (permalink / raw)
  To: David Thompson; +Cc: Andy Wingo, guix-devel

David Thompson <dthompson2@worcester.edu> skribis:

> Andy Wingo <wingo@pobox.com> writes:
>
>> Two patches attached.
>>
>> Unfortunately to use this you need to expand out %base-services to add
>> upower to the udev-service form.  Also you need the upower-service,
>> obviously, and upower needs to be added to the dbus-service form as
>> well.
>
> This isn't the first time I've seen people expanding out %base-services,
> and I was also planning to do so for my OS config.  I wonder if we
> should create a 'make-base-services' procedure that accomodates the
> common tweaks to the %base-services list: the MOTD, the list of packages
> for dbus-service, etc.

In commit 4c9050c, I documented a trick to handle the situation where we
want to customize ‘nscd-service’ as an example:

     As an example, the declaration below configures the NSS to use the
  ‘nss-mdns’ back-end (http://0pointer.de/lennart/projects/nss-mdns/),
  which supports host name lookups over multicast DNS (mDNS) for host
  names ending in ‘.local’:

  [...]

     Note that, in this case, in addition to setting the
  ‘name-service-switch’ of the ‘operating-system’ declaration,
  ‘nscd-service’ must be told where to find the ‘nss-mdns’ shared library
  (*note ‘nscd-service’: Base Services.).  Since the ‘nscd’ service is
  part of %BASE-SERVICES, you may want to customize it by adding this
  snippet in the operating system configuration file:

       (use-modules (guix) (gnu))

       (define %my-base-services
         ;; Replace the default nscd service with one that knows
         ;; about nss-mdns.
         (map (lambda (mservice)
                ;; "Bind" the MSERVICE monadic value to inspect it.
                (mlet %store-monad ((service mservice))
                  (if (member 'nscd (service-provision service))
                      (nscd-service (nscd-configuration)
                                    #:name-services (list nss-mdns))
                      mservice)))
              %base-services))

  … and then refer to %MY-BASE-SERVICES instead of %BASE-SERVICES in the
  ‘operating-system’ declaration.

Not ideal, but that’s what we can do for now.

Ludo’.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add upower
  2015-04-04 19:56 [PATCH] Add upower Andy Wingo
  2015-04-05 14:55 ` David Thompson
  2015-04-05 15:07 ` Mark H Weaver
@ 2015-04-12 22:05 ` Ludovic Courtès
  2 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2015-04-12 22:05 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guix-devel

Andy Wingo <wingo@pobox.com> skribis:

> Two patches attached.
>
> Unfortunately to use this you need to expand out %base-services to add
> upower to the udev-service form.  Also you need the upower-service,
> obviously, and upower needs to be added to the dbus-service form as
> well.

I suggest that we come up with a %desktop-services that will provide a
good default for desktop stuff (Avahi, upower, colord, etc.)

WDYT?

> From 4725d267b7c18bc4ba4294f90336871311386bb2 Mon Sep 17 00:00:00 2001
> From: Andy Wingo <wingo@pobox.com>
> Date: Sat, 4 Apr 2015 21:48:01 +0200
> Subject: [PATCH 2/3] Add upower package.
>
> * gnu/packages/gnome.scm (upower): New variable.
> * gnu/packages/patches/upower-builddir.patch: New patch.

[...]

> From ee0d6fa2b5951edca3c79e3046b42226aca0540a Mon Sep 17 00:00:00 2001
> From: Andy Wingo <wingo@pobox.com>
> Date: Sat, 4 Apr 2015 21:49:02 +0200
> Subject: [PATCH 3/3] Add upower service.
>
> * gnu-system.am (GNU_SYSTEM_MODULES): Add gnu/services/upower.scm.
> * gnu/services/upower.scm: New file, defining a upower service.

Pushed both to ‘core-updates’ with minor tweaks based on David’s review.

Thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-04-12 22:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-04 19:56 [PATCH] Add upower Andy Wingo
2015-04-05 14:55 ` David Thompson
2015-04-05 20:33   ` Making service values transparent Ludovic Courtès
2015-04-12 21:01   ` [PATCH] Add upower Ludovic Courtès
2015-04-05 15:07 ` Mark H Weaver
2015-04-12 22:05 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).