28e5f72f05
This has the nice side-effect of making gpsd actually run! Old behaviour (debugLevel=2): systemd[1]: gpsd.service holdoff time over, scheduling restart. systemd[1]: Stopping GPSD daemon... systemd[1]: Starting GPSD daemon... systemd[1]: gpsd.service start request repeated too quickly, refusing to start. systemd[1]: Failed to start GPSD daemon. systemd[1]: Unit gpsd.service entered failed state. New behaviour (debugLevel=2): gpsd[945]: gpsd: launching (Version 2.95) systemd[1]: Started GPSD daemon. gpsd[945]: gpsd: listening on port 2947 gpsd[945]: gpsd: running with effective group ID 27 gpsd[945]: gpsd: running with effective user ID 23 gpsd[945]: gpsd: stashing device /dev/ttyUSB0 at slot 0
105 lines
2.5 KiB
Nix
105 lines
2.5 KiB
Nix
{ config, pkgs, ... }:
|
|
|
|
with pkgs.lib;
|
|
|
|
let
|
|
|
|
uid = config.ids.uids.gpsd;
|
|
gid = config.ids.gids.gpsd;
|
|
cfg = config.services.gpsd;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.gpsd = {
|
|
|
|
enable = mkOption {
|
|
default = false;
|
|
description = ''
|
|
Whether to enable `gpsd', a GPS service daemon.
|
|
'';
|
|
};
|
|
|
|
device = mkOption {
|
|
default = "/dev/ttyUSB0";
|
|
description = ''
|
|
A device may be a local serial device for GPS input, or a URL of the form:
|
|
<literal>[{dgpsip|ntrip}://][user:passwd@]host[:port][/stream]</literal>
|
|
in which case it specifies an input source for DGPS or ntrip data.
|
|
'';
|
|
};
|
|
|
|
readonly = mkOption {
|
|
default = true;
|
|
description = ''
|
|
Whether to enable the broken-device-safety, otherwise
|
|
known as read-only mode. Some popular bluetooth and USB
|
|
receivers lock up or become totally inaccessible when
|
|
probed or reconfigured. This switch prevents gpsd from
|
|
writing to a receiver. This means that gpsd cannot
|
|
configure the receiver for optimal performance, but it
|
|
also means that gpsd cannot break the receiver. A better
|
|
solution would be for Bluetooth to not be so fragile. A
|
|
platform independent method to identify
|
|
serial-over-Bluetooth devices would also be nice.
|
|
'';
|
|
};
|
|
|
|
port = mkOption {
|
|
default = 2947;
|
|
description = ''
|
|
The port where to listen for TCP connections.
|
|
'';
|
|
};
|
|
|
|
debugLevel = mkOption {
|
|
default = 0;
|
|
description = ''
|
|
The debugging level.
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
users.extraUsers = singleton
|
|
{ name = "gpsd";
|
|
inherit uid;
|
|
description = "gpsd daemon user";
|
|
home = "/var/empty";
|
|
};
|
|
|
|
users.extraGroups = singleton
|
|
{ name = "gpsd";
|
|
inherit gid;
|
|
};
|
|
|
|
systemd.services.gpsd = {
|
|
description = "GPSD daemon";
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network.target" ];
|
|
serviceConfig = {
|
|
Type = "forking";
|
|
ExecStart = ''
|
|
${pkgs.gpsd}/sbin/gpsd -D "${toString cfg.debugLevel}" \
|
|
-S "${toString cfg.port}" \
|
|
${if cfg.readonly then "-b" else ""} \
|
|
"${cfg.device}"
|
|
'';
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
}
|