2014-04-24 23:32:32 +02:00
|
|
|
# GeoClue 2 daemon.
|
|
|
|
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
2018-08-09 16:29:07 +02:00
|
|
|
let
|
|
|
|
# the demo agent isn't built by default, but we need it here
|
|
|
|
package = pkgs.geoclue2.override { withDemoAgent = config.services.geoclue2.enableDemoAgent; };
|
|
|
|
in
|
2014-04-24 23:32:32 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.geoclue2 = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to enable GeoClue 2 daemon, a DBus service
|
2017-10-21 07:24:37 +02:00
|
|
|
that provides location information for accessing.
|
2014-04-24 23:32:32 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-08-09 16:29:07 +02:00
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2014-04-24 23:32:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf config.services.geoclue2.enable {
|
|
|
|
|
2018-08-09 16:29:07 +02:00
|
|
|
environment.systemPackages = [ package ];
|
|
|
|
|
|
|
|
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" ];
|
|
|
|
};
|
|
|
|
};
|
2018-12-20 18:46:05 +01:00
|
|
|
|
|
|
|
environment.etc."geoclue/geoclue.conf".source = "${package}/etc/geoclue/geoclue.conf";
|
2014-04-24 23:32:32 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|