git.iko.soy/typeable/nixpkgs
on master help sign in
upower: use newer version by default

Tested on KDE4, fixed with xfce, and was used with GNOME before. CC @lethalman. I did not test e19, as it won't build, probably due to #5392 @shlevy. CC maintainer @matejc. Also removed a forgotten unused patch.

commit3c050d00a54ec026314a8e978330d4ebbb3037f9 authorVladimír Čunát <vcunat@gmail.com> dateSat 27 Dec 2014, 22:41 (12 years ago) parentca80e41
4 files changed+2−474
nixos/modules/services/x11/desktop-managers/gnome3.nix−1 pkgs/desktops/gnome-3/3.12/default.nix−1 pkgs/desktops/xfce/core/xfce4-session-systemd.patch−470 pkgs/top-level/all-packages.nix+2−2
nixos/modules/services/x11/desktop-managers/gnome3.nix−1
@@ -80,7 +80,6 @@ in {
8080 services.telepathy.enable = mkDefault true;
8181 networking.networkmanager.enable = mkDefault true;
8282 services.upower.enable = config.powerManagement.enable;
83− services.upower.package = gnome3.upower;
8483
8584 fonts.fonts = [ pkgs.dejavu_fonts pkgs.cantarell_fonts ];
8685
pkgs/desktops/gnome-3/3.12/default.nix−1
@@ -10,7 +10,6 @@ rec {
1010 clutter-gst = pkgs.clutter-gst.override { inherit clutter; };
1111 cogl = pkgs.cogl_1_18;
1212
13− upower = pkgs.upower_99;
1413 gtk = gtk3; # just to be sure
1514 libcanberra = pkgs.libcanberra_gtk3; # just to be sure
1615 inherit (pkgs.gnome2) ORBit2;
pkgs/desktops/xfce/core/xfce4-session-systemd.patchdeleted−470
@@ -1,470 +0,0 @@
1−From ae28aef315a7a6b90f1649ce6d1f30b842791cbf Mon Sep 17 00:00:00 2001
2−From: Nick Schermer <nick@xfce.org>
3−Date: Sun, 04 Nov 2012 20:23:36 +0000
4−Subject: Add shutdown/reboot functionality for systemd (bug #8729).
5−
6−Based on patch by Christian Hesse and Evangelos Foutras.
7−---
8−diff --git a/configure.in.in b/configure.in.in
9−index 9aa4f8f..134d0f7 100644
10−--- a/configure.in
11−+++ b/configure.in
12−@@ -96,6 +96,10 @@ XDT_CHECK_PACKAGE([DBUS], [dbus-1], [1.1.0])
13− XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [0.84])
14− XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.9.0])
15−
16−+dnl Check for polkit / systemd integration
17−+XDT_CHECK_OPTIONAL_PACKAGE([SYSTEMD], [polkit-gobject-1], [0.100],
18−+ [systemd], [Systemd support (through polit)])
19−+
20− dnl Check for debugging support
21− XDT_FEATURE_DEBUG([xfsm_debug_default])
22−
23−diff --git a/xfce4-session/Makefile.am b/xfce4-session/Makefile.am
24−index c015154..f748b2b 100644
25−--- a/xfce4-session/Makefile.am
26−+++ b/xfce4-session/Makefile.am
27−@@ -38,8 +38,6 @@ xfce4_session_SOURCES = \
28− xfsm-compat-gnome.h \
29− xfsm-compat-kde.c \
30− xfsm-compat-kde.h \
31−- xfsm-consolekit.c \
32−- xfsm-consolekit.h \
33− xfsm-dns.c \
34− xfsm-dns.h \
35− xfsm-error.c \
36−@@ -65,6 +63,16 @@ xfce4_session_SOURCES = \
37− xfsm-upower.c \
38− xfsm-upower.h
39−
40−+if HAVE_SYSTEMD
41−+xfce4_session_SOURCES += \
42−+ xfsm-systemd.c \
43−+ xfsm-systemd.h
44−+else
45−+xfce4_session_SOURCES += \
46−+ xfsm-consolekit.c \
47−+ xfsm-consolekit.h
48−+endif
49−+
50− xfce4_session_CFLAGS = \
51− $(LIBSM_CFLAGS) \
52− $(LIBX11_CFLAGS) \
53−@@ -72,6 +80,7 @@ xfce4_session_CFLAGS = \
54− $(DBUS_CFLAGS) \
55− $(DBUS_GLIB_CFLAGS) \
56− $(LIBWNCK_CFLAGS) \
57−+ $(SYSTEMD_CFLAGS) \
58− $(XFCONF_CFLAGS) \
59− $(GMODULE_CFLAGS) \
60− $(PLATFORM_CFLAGS)
61−@@ -91,6 +100,7 @@ xfce4_session_LDADD = \
62− $(DBUS_LIBS) \
63− $(DBUS_GLIB_LIBS) \
64− $(LIBWNCK_LIBS) \
65−+ $(SYSTEMD_LIBS) \
66− $(XFCONF_LIBS) \
67− -lm
68−
69−diff --git a/xfce4-session/xfsm-shutdown.c b/xfce4-session/xfsm-shutdown.c
70−index d8757a8..4c483a7 100644
71−--- a/xfce4-session/xfsm-shutdown.c
72−+++ b/xfce4-session/xfsm-shutdown.c
73−@@ -66,10 +66,13 @@
74− #include <xfce4-session/xfsm-fadeout.h>
75− #include <xfce4-session/xfsm-global.h>
76− #include <xfce4-session/xfsm-legacy.h>
77−-#include <xfce4-session/xfsm-consolekit.h>
78− #include <xfce4-session/xfsm-upower.h>
79−
80−-
81−+#ifdef HAVE_SYSTEMD
82−+#include <xfce4-session/xfsm-systemd.h>
83−+#else
84−+#include <xfce4-session/xfsm-consolekit.h>
85−+#endif
86−
87− static void xfsm_shutdown_finalize (GObject *object);
88− static void xfsm_shutdown_sudo_free (XfsmShutdown *shutdown);
89−@@ -93,7 +96,11 @@ struct _XfsmShutdown
90− {
91− GObject __parent__;
92−
93−+#ifdef HAVE_SYSTEMD
94−+ XfsmSystemd *systemd;
95−+#else
96− XfsmConsolekit *consolekit;
97−+#endif
98− XfsmUPower *upower;
99−
100− /* kiosk settings */
101−@@ -131,7 +138,11 @@ xfsm_shutdown_init (XfsmShutdown *shutdown)
102− {
103− XfceKiosk *kiosk;
104−
105−+#ifdef HAVE_SYSTEMD
106−+ shutdown->systemd = xfsm_systemd_get ();
107−+#else
108− shutdown->consolekit = xfsm_consolekit_get ();
109−+#endif
110− shutdown->upower = xfsm_upower_get ();
111− shutdown->helper_state = SUDO_NOT_INITIAZED;
112− shutdown->helper_require_password = FALSE;
113−@@ -150,7 +161,11 @@ xfsm_shutdown_finalize (GObject *object)
114− {
115− XfsmShutdown *shutdown = XFSM_SHUTDOWN (object);
116−
117−+#ifdef HAVE_SYSTEMD
118−+ g_object_unref (G_OBJECT (shutdown->systemd));
119−+#else
120− g_object_unref (G_OBJECT (shutdown->consolekit));
121−+#endif
122− g_object_unref (G_OBJECT (shutdown->upower));
123−
124− /* close down helper */
125−@@ -641,7 +656,11 @@ xfsm_shutdown_try_restart (XfsmShutdown *shutdown,
126− if (shutdown->helper_state == SUDO_AVAILABLE)
127− return xfsm_shutdown_sudo_try_action (shutdown, XFSM_SHUTDOWN_RESTART, error);
128− else
129−+#ifdef HAVE_SYSTEMD
130−+ return xfsm_systemd_try_restart (shutdown->systemd, error);
131−+#else
132− return xfsm_consolekit_try_restart (shutdown->consolekit, error);
133−+#endif
134− }
135−
136−
137−@@ -658,7 +677,11 @@ xfsm_shutdown_try_shutdown (XfsmShutdown *shutdown,
138− if (shutdown->helper_state == SUDO_AVAILABLE)
139− return xfsm_shutdown_sudo_try_action (shutdown, XFSM_SHUTDOWN_SHUTDOWN, error);
140− else
141−+#ifdef HAVE_SYSTEMD
142−+ return xfsm_systemd_try_shutdown (shutdown->systemd, error);
143−+#else
144− return xfsm_consolekit_try_shutdown (shutdown->consolekit, error);
145−+#endif
146− }
147−
148−
149−@@ -698,7 +721,11 @@ xfsm_shutdown_can_restart (XfsmShutdown *shutdown,
150− return TRUE;
151− }
152−
153−+#ifdef HAVE_SYSTEMD
154−+ if (xfsm_systemd_can_restart (shutdown->systemd, can_restart, error))
155−+#else
156− if (xfsm_consolekit_can_restart (shutdown->consolekit, can_restart, error))
157−+#endif
158− return TRUE;
159−
160− if (xfsm_shutdown_sudo_init (shutdown, error))
161−@@ -725,7 +752,11 @@ xfsm_shutdown_can_shutdown (XfsmShutdown *shutdown,
162− return TRUE;
163− }
164−
165−+#ifdef HAVE_SYSTEMD
166−+ if (xfsm_systemd_can_shutdown (shutdown->systemd, can_shutdown, error))
167−+#else
168− if (xfsm_consolekit_can_shutdown (shutdown->consolekit, can_shutdown, error))
169−+#endif
170− return TRUE;
171−
172− if (xfsm_shutdown_sudo_init (shutdown, error))
173−diff --git a/xfce4-session/xfsm-systemd.c b/xfce4-session/xfsm-systemd.c
174−new file mode 100644
175−index 0000000..7bdd39d
176−--- /dev/null
177−+++ b/xfce4-session/xfsm-systemd.c
178−@@ -0,0 +1,229 @@
179−+/*-
180−+ * Copyright (C) 2012 Christian Hesse
181−+ *
182−+ * This program is free software; you can redistribute it and/or modify
183−+ * it under the terms of the GNU General Public License as published by
184−+ * the Free Software Foundation; either version 2, or (at your option)
185−+ * any later version.
186−+ *
187−+ * This program is distributed in the hope that it will be useful,
188−+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
189−+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
190−+ * GNU General Public License for more details.
191−+ *
192−+ * You should have received a copy of the GNU General Public License
193−+ * along with this program; if not, write to the Free Software
194−+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
195−+ * MA 02110-1301 USA.
196−+ */
197−+
198−+#include <config.h>
199−+
200−+#include <gio/gio.h>
201−+#include <polkit/polkit.h>
202−+#include <dbus/dbus-glib.h>
203−+#include <dbus/dbus-glib-lowlevel.h>
204−+
205−+#include <xfce4-session/xfsm-systemd.h>
206−+
207−+
208−+
209−+#define SYSTEMD_DBUS_NAME "org.freedesktop.login1"
210−+#define SYSTEMD_DBUS_PATH "/org/freedesktop/login1"
211−+#define SYSTEMD_DBUS_INTERFACE "org.freedesktop.login1.Manager"
212−+#define SYSTEMD_REBOOT_ACTION "Reboot"
213−+#define SYSTEMD_POWEROFF_ACTION "PowerOff"
214−+#define SYSTEMD_REBOOT_TEST "org.freedesktop.login1.reboot"
215−+#define SYSTEMD_POWEROFF_TEST "org.freedesktop.login1.power-off"
216−+
217−+
218−+
219−+static void xfsm_systemd_finalize (GObject *object);
220−+
221−+
222−+
223−+struct _XfsmSystemdClass
224−+{
225−+ GObjectClass __parent__;
226−+};
227−+
228−+struct _XfsmSystemd
229−+{
230−+ GObject __parent__;
231−+
232−+ PolkitAuthority *authority;
233−+ PolkitSubject *subject;
234−+};
235−+
236−+
237−+
238−+G_DEFINE_TYPE (XfsmSystemd, xfsm_systemd, G_TYPE_OBJECT)
239−+
240−+
241−+
242−+static void
243−+xfsm_systemd_class_init (XfsmSystemdClass *klass)
244−+{
245−+ GObjectClass *gobject_class;
246−+
247−+ gobject_class = G_OBJECT_CLASS (klass);
248−+ gobject_class->finalize = xfsm_systemd_finalize;
249−+}
250−+
251−+
252−+
253−+static void
254−+xfsm_systemd_init (XfsmSystemd *systemd)
255−+{
256−+ systemd->authority = polkit_authority_get_sync (NULL, NULL);
257−+ systemd->subject = polkit_unix_process_new (getpid());
258−+}
259−+
260−+
261−+
262−+static void
263−+xfsm_systemd_finalize (GObject *object)
264−+{
265−+ XfsmSystemd *systemd = XFSM_SYSTEMD (object);
266−+
267−+ g_object_unref (G_OBJECT (systemd->authority));
268−+ g_object_unref (G_OBJECT (systemd->subject));
269−+
270−+ (*G_OBJECT_CLASS (xfsm_systemd_parent_class)->finalize) (object);
271−+}
272−+
273−+
274−+static gboolean
275−+xfsm_systemd_can_method (XfsmSystemd *systemd,
276−+ gboolean *can_method,
277−+ const gchar *method,
278−+ GError **error)
279−+{
280−+ PolkitAuthorizationResult *res;
281−+ GError *local_error = NULL;
282−+
283−+ *can_method = FALSE;
284−+
285−+ res = polkit_authority_check_authorization_sync (systemd->authority,
286−+ systemd->subject,
287−+ method,
288−+ NULL,
289−+ POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE,
290−+ NULL,
291−+ &local_error);
292−+
293−+ if (res == NULL)
294−+ {
295−+ g_propagate_error (error, local_error);
296−+ return FALSE;
297−+ }
298−+
299−+ *can_method = polkit_authorization_result_get_is_authorized (res)
300−+ || polkit_authorization_result_get_is_challenge (res);
301−+
302−+ g_object_unref (G_OBJECT (res));
303−+
304−+ return TRUE;
305−+}
306−+
307−+
308−+
309−+static gboolean
310−+xfsm_systemd_try_method (XfsmSystemd *systemd,
311−+ const gchar *method,
312−+ GError **error)
313−+{
314−+ GDBusConnection *bus;
315−+ GError *local_error = NULL;
316−+
317−+ bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, error);
318−+ if (G_UNLIKELY (bus == NULL))
319−+ return FALSE;
320−+
321−+ g_dbus_connection_call_sync (bus,
322−+ SYSTEMD_DBUS_NAME,
323−+ SYSTEMD_DBUS_PATH,
324−+ SYSTEMD_DBUS_INTERFACE,
325−+ method,
326−+ g_variant_new ("(b)", TRUE),
327−+ NULL, 0, G_MAXINT, NULL,
328−+ &local_error);
329−+
330−+ g_object_unref (G_OBJECT (bus));
331−+
332−+ if (local_error != NULL)
333−+ {
334−+ g_propagate_error (error, local_error);
335−+ return FALSE;
336−+ }
337−+
338−+ return TRUE;
339−+}
340−+
341−+
342−+
343−+XfsmSystemd *
344−+xfsm_systemd_get (void)
345−+{
346−+ static XfsmSystemd *object = NULL;
347−+
348−+ if (G_LIKELY (object != NULL))
349−+ {
350−+ g_object_ref (G_OBJECT (object));
351−+ }
352−+ else
353−+ {
354−+ object = g_object_new (XFSM_TYPE_SYSTEMD, NULL);
355−+ g_object_add_weak_pointer (G_OBJECT (object), (gpointer) &object);
356−+ }
357−+
358−+ return object;
359−+}
360−+
361−+
362−+
363−+gboolean
364−+xfsm_systemd_try_restart (XfsmSystemd *systemd,
365−+ GError **error)
366−+{
367−+ return xfsm_systemd_try_method (systemd,
368−+ SYSTEMD_REBOOT_ACTION,
369−+ error);
370−+}
371−+
372−+
373−+
374−+gboolean
375−+xfsm_systemd_try_shutdown (XfsmSystemd *systemd,
376−+ GError **error)
377−+{
378−+ return xfsm_systemd_try_method (systemd,
379−+ SYSTEMD_POWEROFF_ACTION,
380−+ error);
381−+}
382−+
383−+
384−+
385−+gboolean
386−+xfsm_systemd_can_restart (XfsmSystemd *systemd,
387−+ gboolean *can_restart,
388−+ GError **error)
389−+{
390−+ return xfsm_systemd_can_method (systemd,
391−+ can_restart,
392−+ SYSTEMD_REBOOT_TEST,
393−+ error);
394−+}
395−+
396−+
397−+
398−+gboolean
399−+xfsm_systemd_can_shutdown (XfsmSystemd *systemd,
400−+ gboolean *can_shutdown,
401−+ GError **error)
402−+{
403−+ return xfsm_systemd_can_method (systemd,
404−+ can_shutdown,
405−+ SYSTEMD_POWEROFF_TEST,
406−+ error);
407−+}
408−diff --git a/xfce4-session/xfsm-systemd.h b/xfce4-session/xfsm-systemd.h
409−new file mode 100644
410−index 0000000..8223622
411−--- /dev/null
412−+++ b/xfce4-session/xfsm-systemd.h
413−@@ -0,0 +1,55 @@
414−+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
415−+ *
416−+ * Copyright (C) 2012 Christian Hesse
417−+ *
418−+ * Licensed under the GNU General Public License Version 2
419−+ *
420−+ * This program is free software; you can redistribute it and/or modify
421−+ * it under the terms of the GNU General Public License as published by
422−+ * the Free Software Foundation; either version 2 of the License, or
423−+ * (at your option) any later version.
424−+ *
425−+ * This program is distributed in the hope that it will be useful,
426−+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
427−+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
428−+ * GNU General Public License for more details.
429−+ *
430−+ * You should have received a copy of the GNU General Public License
431−+ * along with this program; if not, write to the Free Software
432−+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
433−+ */
434−+
435−+#ifndef __XFSM_SYSTEMD_H__
436−+#define __XFSM_SYSTEMD_H__
437−+
438−+typedef struct _XfsmSystemdClass XfsmSystemdClass;
439−+typedef struct _XfsmSystemd XfsmSystemd;
440−+
441−+#define XFSM_TYPE_SYSTEMD (xfsm_systemd_get_type ())
442−+#define XFSM_SYSTEMD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XFSM_TYPE_SYSTEMD, XfsmSystemd))
443−+#define XFSM_SYSTEMD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), XFSM_TYPE_SYSTEMD, XfsmSystemdClass))
444−+#define XFSM_IS_SYSTEMD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFSM_TYPE_SYSTEMD))
445−+#define XFSM_IS_SYSTEMD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), XFSM_TYPE_SYSTEMD))
446−+#define XFSM_SYSTEMD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XFSM_TYPE_SYSTEMD, XfsmSystemdClass))
447−+
448−+GType xfsm_systemd_get_type (void) G_GNUC_CONST;
449−+
450−+XfsmSystemd *xfsm_systemd_get (void);
451−+
452−+gboolean xfsm_systemd_try_restart (XfsmSystemd *systemd,
453−+ GError **error);
454−+
455−+gboolean xfsm_systemd_try_shutdown (XfsmSystemd *systemd,
456−+ GError **error);
457−+
458−+gboolean xfsm_systemd_can_restart (XfsmSystemd *systemd,
459−+ gboolean *can_restart,
460−+ GError **error);
461−+
462−+gboolean xfsm_systemd_can_shutdown (XfsmSystemd *systemd,
463−+ gboolean *can_shutdown,
464−+ GError **error);
465−+
466−+G_END_DECLS
467−+
468−+#endif /* __XFSM_SYSTEMD_H__ */
469−--
470−cgit v0.9.1
pkgs/top-level/all-packages.nix+2−2
@@ -8726,9 +8726,9 @@ let
87268726
87278727 untie = callPackage ../os-specific/linux/untie { };
87288728
8729− upower = callPackage ../os-specific/linux/upower { };
8729+ upower-old = callPackage ../os-specific/linux/upower { };
87308730
8731− upower_99 = callPackage ../os-specific/linux/upower/0.99.nix { };
8731+ upower = callPackage ../os-specific/linux/upower/0.99.nix { };
87328732
87338733 upstart = callPackage ../os-specific/linux/upstart { };
87348734