9 cfg = config.services.geoclue2;
13 "io.elementary.desktop.agent-geoclue2"
16 appConfigModule = lib.types.submodule (
20 desktopID = lib.mkOption {
22 description = "Desktop ID of the application.";
25 isAllowed = lib.mkOption {
26 type = lib.types.bool;
28 Whether the application will be allowed access to location information.
32 isSystem = lib.mkOption {
33 type = lib.types.bool;
35 Whether the application is a system component or not.
39 users = lib.mkOption {
40 type = lib.types.listOf lib.types.str;
43 List of UIDs of all users for which this application is allowed location
44 info access, Defaults to an empty string to allow it for all users.
49 config.desktopID = lib.mkDefault name;
53 appConfigToINICompatible =
67 users = lib.concatStringsSep ";" users;
80 enable = lib.mkOption {
81 type = lib.types.bool;
84 Whether to enable GeoClue 2 daemon, a DBus service
85 that provides location information for accessing.
89 enableDemoAgent = lib.mkOption {
90 type = lib.types.bool;
93 Whether to use the GeoClue demo agent. This should be
94 overridden by desktop environments that provide their own
99 enableNmea = lib.mkOption {
100 type = lib.types.bool;
103 Whether to fetch location from NMEA sources on local network.
107 enable3G = lib.mkOption {
108 type = lib.types.bool;
111 Whether to enable 3G source.
115 enableCDMA = lib.mkOption {
116 type = lib.types.bool;
119 Whether to enable CDMA source.
123 enableModemGPS = lib.mkOption {
124 type = lib.types.bool;
127 Whether to enable Modem-GPS source.
131 enableWifi = lib.mkOption {
132 type = lib.types.bool;
135 Whether to enable WiFi source.
139 geoProviderUrl = lib.mkOption {
140 type = lib.types.str;
141 default = "https://location.services.mozilla.com/v1/geolocate?key=geoclue";
142 example = "https://www.googleapis.com/geolocation/v1/geolocate?key=YOUR_KEY";
144 The url to the wifi GeoLocation Service.
148 package = lib.mkOption {
149 type = lib.types.package;
150 default = pkgs.geoclue2;
151 defaultText = lib.literalExpression "pkgs.geoclue2";
155 # the demo agent isn't built by default, but we need it here
156 withDemoAgent = cfg.enableDemoAgent;
158 description = "The geoclue2 package to use";
161 submitData = lib.mkOption {
162 type = lib.types.bool;
165 Whether to submit data to a GeoLocation Service.
169 submissionUrl = lib.mkOption {
170 type = lib.types.str;
171 default = "https://location.services.mozilla.com/v1/submit?key=geoclue";
173 The url to submit data to a GeoLocation Service.
177 submissionNick = lib.mkOption {
178 type = lib.types.str;
181 A nickname to submit network data with.
182 Must be 2-32 characters long.
186 appConfig = lib.mkOption {
187 type = lib.types.attrsOf appConfigModule;
189 example = lib.literalExpression ''
197 Specify extra settings per application.
205 ###### implementation
206 config = lib.mkIf cfg.enable {
208 environment.systemPackages = [ cfg.package ];
210 services.dbus.packages = [ cfg.package ];
212 systemd.packages = [ cfg.package ];
214 # we cannot use DynamicUser as we need the the geoclue user to exist for the
215 # dbus policy to work
219 home = "/var/lib/geoclue";
221 description = "Geoinformation service";
224 groups.geoclue = { };
227 systemd.services.geoclue = {
228 wants = lib.optionals cfg.enableWifi [ "network-online.target" ];
229 after = lib.optionals cfg.enableWifi [ "network-online.target" ];
230 # restart geoclue service when the configuration changes
232 config.environment.etc."geoclue/geoclue.conf".source
234 serviceConfig.StateDirectory = "geoclue";
237 # this needs to run as a user service, since it's associated with the
238 # user who is making the requests
239 systemd.user.services = lib.mkIf cfg.enableDemoAgent {
241 description = "Geoclue agent";
242 # this should really be `partOf = [ "geoclue.service" ]`, but
243 # we can't be part of a system service, and the agent should
244 # be okay with the main service coming and going
245 wantedBy = [ "default.target" ];
246 wants = lib.optionals cfg.enableWifi [ "network-online.target" ];
247 after = lib.optionals cfg.enableWifi [ "network-online.target" ];
248 unitConfig.ConditionUser = "!@system";
251 ExecStart = "${cfg.package}/libexec/geoclue-2.0/demos/agent";
252 Restart = "on-failure";
258 services.geoclue2.appConfig.epiphany = {
263 services.geoclue2.appConfig.firefox = {
268 environment.etc."geoclue/geoclue.conf".text = lib.generators.toINI { } (
271 whitelist = lib.concatStringsSep ";" (
272 lib.optional cfg.enableDemoAgent "geoclue-demo-agent" ++ defaultWhitelist
276 enable = cfg.enableNmea;
279 enable = cfg.enable3G;
282 enable = cfg.enableCDMA;
285 enable = cfg.enableModemGPS;
288 enable = cfg.enableWifi;
289 url = cfg.geoProviderUrl;
290 submit-data = lib.boolToString cfg.submitData;
291 submission-url = cfg.submissionUrl;
292 submission-nick = cfg.submissionNick;
295 // lib.mapAttrs' appConfigToINICompatible cfg.appConfig
300 maintainers = with maintainers; [ ] ++ teams.pantheon.members;