1 { config, lib, pkgs, utils, ... }:
4 uid = config.ids.uids.gpsd;
5 gid = config.ids.gids.gpsd;
6 cfg = config.services.gpsd;
13 (lib.mkRemovedOptionModule [ "services" "gpsd" "device" ]
14 "Use `services.gpsd.devices` instead.")
21 enable = lib.mkOption {
22 type = lib.types.bool;
25 Whether to enable `gpsd`, a GPS service daemon.
29 devices = lib.mkOption {
30 type = lib.types.listOf lib.types.str;
31 default = [ "/dev/ttyUSB0" ];
33 List of devices that `gpsd` should subscribe to.
35 A device may be a local serial device for GPS input, or a
37 `[{dgpsip|ntrip}://][user:passwd@]host[:port][/stream]` in
38 which case it specifies an input source for DGPS or ntrip
43 readonly = lib.mkOption {
44 type = lib.types.bool;
47 Whether to enable the broken-device-safety, otherwise
48 known as read-only mode. Some popular bluetooth and USB
49 receivers lock up or become totally inaccessible when
50 probed or reconfigured. This switch prevents gpsd from
51 writing to a receiver. This means that gpsd cannot
52 configure the receiver for optimal performance, but it
53 also means that gpsd cannot break the receiver. A better
54 solution would be for Bluetooth to not be so fragile. A
55 platform independent method to identify
56 serial-over-Bluetooth devices would also be nice.
60 nowait = lib.mkOption {
61 type = lib.types.bool;
64 don't wait for client connects to poll GPS
69 type = lib.types.port;
72 The port where to listen for TCP connections.
76 debugLevel = lib.mkOption {
84 listenany = lib.mkOption {
85 type = lib.types.bool;
88 Listen on all addresses rather than just loopback.
92 extraArgs = lib.mkOption {
93 type = lib.types.listOf lib.types.str;
95 example = [ "-r" "-s" "19200" ];
97 A list of extra command line arguments to pass to gpsd.
98 Check gpsd(8) mangpage for possible arguments.
106 ###### implementation
108 config = lib.mkIf cfg.enable {
113 description = "gpsd daemon user";
117 users.groups.gpsd = { inherit gid; };
119 systemd.services.gpsd = {
120 description = "GPSD daemon";
121 wantedBy = [ "multi-user.target" ];
122 after = [ "network.target" ];
126 devices = utils.escapeSystemdExecArgs cfg.devices;
127 extraArgs = utils.escapeSystemdExecArgs cfg.extraArgs;
129 ${pkgs.gpsd}/sbin/gpsd -D "${toString cfg.debugLevel}" \
130 -S "${toString cfg.port}" \
131 ${lib.optionalString cfg.readonly "-b"} \
132 ${lib.optionalString cfg.nowait "-n"} \
133 ${lib.optionalString cfg.listenany "-G"} \