From a1762065c3696530789109d37781dedb0400e140 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Thu, 9 Aug 2018 15:17:43 +0100 Subject: [PATCH 1/4] redshift: install desktop files, and use absolute paths in them to avoid confusing geoclue agent --- nixos/modules/services/x11/redshift.nix | 3 +++ pkgs/applications/misc/redshift/default.nix | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/nixos/modules/services/x11/redshift.nix b/nixos/modules/services/x11/redshift.nix index 30d853841ea4..b7dd7debcb63 100644 --- a/nixos/modules/services/x11/redshift.nix +++ b/nixos/modules/services/x11/redshift.nix @@ -116,6 +116,9 @@ in { } ]; + # needed so that .desktop files are installed, which geoclue cares about + environment.systemPackages = [ cfg.package ]; + services.geoclue2.enable = mkIf (cfg.provider == "geoclue2") true; systemd.user.services.redshift = diff --git a/pkgs/applications/misc/redshift/default.nix b/pkgs/applications/misc/redshift/default.nix index c6d3d6e1a9d5..b8c49cb02a69 100644 --- a/pkgs/applications/misc/redshift/default.nix +++ b/pkgs/applications/misc/redshift/default.nix @@ -61,6 +61,15 @@ stdenv.mkDerivation rec { postFixup = "wrapPythonPrograms"; + # the geoclue agent may inspect these paths and expect them to be + # valid without having the correct $PATH set + postInstall = '' + substituteInPlace $out/share/applications/redshift.desktop \ + --replace 'Exec=redshift' "Exec=$out/bin/redshift" + substituteInPlace $out/share/applications/redshift.desktop \ + --replace 'Exec=redshift-gtk' "Exec=$out/bin/redshift-gtk" + ''; + enableParallelBuilding = true; meta = with stdenv.lib; { From 284fc9b4496aa2032ac1bb82a2556a3055084398 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Thu, 9 Aug 2018 15:20:28 +0100 Subject: [PATCH 2/4] geoclue: 2.4.10 -> 2.4.12 --- pkgs/development/libraries/geoclue/default.nix | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pkgs/development/libraries/geoclue/default.nix b/pkgs/development/libraries/geoclue/default.nix index 2588d7f3d547..8417719b7063 100644 --- a/pkgs/development/libraries/geoclue/default.nix +++ b/pkgs/development/libraries/geoclue/default.nix @@ -7,17 +7,19 @@ with stdenv.lib; stdenv.mkDerivation rec { name = "geoclue-${version}"; - version = "2.4.10"; + version = "2.4.12"; src = fetchurl { url = "https://www.freedesktop.org/software/geoclue/releases/${stdenv.lib.versions.majorMinor version}/${name}.tar.xz"; - sha256 = "0h4n8jf7w457sglfdhghkyf8n4v4a5jrx8dgdy5zn35nbscx24l4"; + sha256 = "1jnad1f3rf8h05sz1lc172jnqdhqdpz76ff6m7i5ss3s0znf5l05"; }; outputs = [ "out" "dev" "devdoc" ]; nativeBuildInputs = [ - pkgconfig intltool gtk-doc docbook_xsl docbook_xml_dtd_412 wrapGAppsHook gobjectIntrospection + pkgconfig intltool wrapGAppsHook gobjectIntrospection + # devdoc + gtk-doc docbook_xsl docbook_xml_dtd_412 ]; buildInputs = [ @@ -41,11 +43,6 @@ stdenv.mkDerivation rec { "--disable-nmea-source" ]; - # https://gitlab.freedesktop.org/geoclue/geoclue/issues/73 - postInstall = '' - sed -i $dev/lib/pkgconfig/libgeoclue-2.0.pc -e "s|includedir=.*|includedir=$dev/include|" - ''; - meta = with stdenv.lib; { description = "Geolocation framework and some data providers"; homepage = https://gitlab.freedesktop.org/geoclue/geoclue/wikis/home; From 316669327c6cb0e85dc522f0b7af55db33474553 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Thu, 9 Aug 2018 15:29:07 +0100 Subject: [PATCH 3/4] geoclue2 service: add option to run demo agent --- nixos/modules/services/desktops/geoclue2.nix | 35 ++++++++++++++++--- .../services/x11/desktop-managers/gnome3.nix | 2 ++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/desktops/geoclue2.nix b/nixos/modules/services/desktops/geoclue2.nix index c5a000d5c6a7..dafb0af20756 100644 --- a/nixos/modules/services/desktops/geoclue2.nix +++ b/nixos/modules/services/desktops/geoclue2.nix @@ -4,6 +4,10 @@ with lib; +let + # the demo agent isn't built by default, but we need it here + package = pkgs.geoclue2.override { withDemoAgent = config.services.geoclue2.enableDemoAgent; }; +in { ###### interface @@ -21,21 +25,42 @@ with lib; ''; }; + enableDemoAgent = mkOption { + type = types.bool; + default = true; + description = '' + Whether to use the GeoClue demo agent. This should be + overridden by desktop environments that provide their own + agent. + ''; + }; + }; }; ###### implementation - config = mkIf config.services.geoclue2.enable { - environment.systemPackages = [ pkgs.geoclue2 ]; + environment.systemPackages = [ package ]; - services.dbus.packages = [ pkgs.geoclue2 ]; - - systemd.packages = [ pkgs.geoclue2 ]; + services.dbus.packages = [ package ]; + systemd.packages = [ package ]; + + # this needs to run as a user service, since it's associated with the + # user who is making the requests + systemd.user.services = mkIf config.services.geoclue2.enableDemoAgent { + "geoclue-agent" = { + description = "Geoclue agent"; + script = "${package}/libexec/geoclue-2.0/demos/agent"; + # this should really be `partOf = [ "geoclue.service" ]`, but + # we can't be part of a system service, and the agent should + # be okay with the main service coming and going + wantedBy = [ "default.target" ]; + }; + }; }; } diff --git a/nixos/modules/services/x11/desktop-managers/gnome3.nix b/nixos/modules/services/x11/desktop-managers/gnome3.nix index 9fb8f44b2421..e000e34cafc4 100644 --- a/nixos/modules/services/x11/desktop-managers/gnome3.nix +++ b/nixos/modules/services/x11/desktop-managers/gnome3.nix @@ -93,6 +93,8 @@ in { services.udisks2.enable = true; services.accounts-daemon.enable = true; services.geoclue2.enable = mkDefault true; + # GNOME should have its own geoclue agent + services.geoclue2.enableDemoAgent = false; services.dleyna-renderer.enable = mkDefault true; services.dleyna-server.enable = mkDefault true; services.gnome3.at-spi2-core.enable = true; From 80d4fa725bc0a61c11c51a392c95561442d795f5 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Thu, 9 Aug 2018 15:50:53 +0100 Subject: [PATCH 4/4] localtime: simplify module a little --- nixos/modules/services/system/localtime.nix | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/nixos/modules/services/system/localtime.nix b/nixos/modules/services/system/localtime.nix index b9355bbb9441..c7e897c96448 100644 --- a/nixos/modules/services/system/localtime.nix +++ b/nixos/modules/services/system/localtime.nix @@ -22,14 +22,8 @@ in { config = mkIf cfg.enable { services.geoclue2.enable = true; - security.polkit.extraConfig = '' - polkit.addRule(function(action, subject) { - if (action.id == "org.freedesktop.timedate1.set-timezone" - && subject.user == "localtimed") { - return polkit.Result.YES; - } - }); - ''; + # so polkit will pick up the rules + environment.systemPackages = [ pkgs.localtime ]; users.users = [{ name = "localtimed";