the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
117 lines
2.8 KiB
Nix
117 lines
2.8 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
uid = config.ids.uids.gpsd;
|
|
gid = config.ids.gids.gpsd;
|
|
cfg = config.services.gpsd;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.gpsd = {
|
|
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc ''
|
|
Whether to enable `gpsd', a GPS service daemon.
|
|
'';
|
|
};
|
|
|
|
device = mkOption {
|
|
type = types.str;
|
|
default = "/dev/ttyUSB0";
|
|
description = lib.mdDoc ''
|
|
A device may be a local serial device for GPS input, or a URL of the form:
|
|
`[{dgpsip|ntrip}://][user:passwd@]host[:port][/stream]`
|
|
in which case it specifies an input source for DGPS or ntrip data.
|
|
'';
|
|
};
|
|
|
|
readonly = mkOption {
|
|
type = types.bool;
|
|
default = true;
|
|
description = lib.mdDoc ''
|
|
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.
|
|
'';
|
|
};
|
|
|
|
nowait = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc ''
|
|
don't wait for client connects to poll GPS
|
|
'';
|
|
};
|
|
|
|
port = mkOption {
|
|
type = types.port;
|
|
default = 2947;
|
|
description = lib.mdDoc ''
|
|
The port where to listen for TCP connections.
|
|
'';
|
|
};
|
|
|
|
debugLevel = mkOption {
|
|
type = types.int;
|
|
default = 0;
|
|
description = lib.mdDoc ''
|
|
The debugging level.
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
users.users.gpsd =
|
|
{ inherit uid;
|
|
group = "gpsd";
|
|
description = "gpsd daemon user";
|
|
home = "/var/empty";
|
|
};
|
|
|
|
users.groups.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}" \
|
|
${optionalString cfg.readonly "-b"} \
|
|
${optionalString cfg.nowait "-n"} \
|
|
"${cfg.device}"
|
|
'';
|
|
};
|
|
};
|
|
|
|
};
|
|
|
|
}
|