1# GeoClue 2 daemon.
2
3{ config, lib, pkgs, ... }:
4
5with lib;
6
7let
8 # the demo agent isn't built by default, but we need it here
9 package = pkgs.geoclue2.override { withDemoAgent = config.services.geoclue2.enableDemoAgent; };
10in
11{
12
13 ###### interface
14
15 options = {
16
17 services.geoclue2 = {
18
19 enable = mkOption {
20 type = types.bool;
21 default = false;
22 description = ''
23 Whether to enable GeoClue 2 daemon, a DBus service
24 that provides location information for accessing.
25 '';
26 };
27
28 enableDemoAgent = mkOption {
29 type = types.bool;
30 default = true;
31 description = ''
32 Whether to use the GeoClue demo agent. This should be
33 overridden by desktop environments that provide their own
34 agent.
35 '';
36 };
37
38 };
39
40 };
41
42
43 ###### implementation
44 config = mkIf config.services.geoclue2.enable {
45
46 environment.systemPackages = [ package ];
47
48 services.dbus.packages = [ package ];
49
50 systemd.packages = [ package ];
51
52 # this needs to run as a user service, since it's associated with the
53 # user who is making the requests
54 systemd.user.services = mkIf config.services.geoclue2.enableDemoAgent {
55 "geoclue-agent" = {
56 description = "Geoclue agent";
57 script = "${package}/libexec/geoclue-2.0/demos/agent";
58 # this should really be `partOf = [ "geoclue.service" ]`, but
59 # we can't be part of a system service, and the agent should
60 # be okay with the main service coming and going
61 wantedBy = [ "default.target" ];
62 };
63 };
64 };
65
66}