mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 08:53:21 +00:00
* Merge some stuff from the trunk.
svn path=/nixos/branches/modular-nixos/; revision=16051
This commit is contained in:
commit
0d5ea86748
@ -46,6 +46,7 @@ in
|
||||
tomcat = 16;
|
||||
gnunetd = 17;
|
||||
pulseaudio = 22; # must match `pulseaudio' GID
|
||||
gpsd = 23;
|
||||
|
||||
nixbld = 30000; # start of range of uids
|
||||
nobody = 65534;
|
||||
@ -73,6 +74,7 @@ in
|
||||
lp = 20;
|
||||
tomcat = 21;
|
||||
pulseaudio = 22; # must match `pulseaudio' UID
|
||||
gpsd = 23;
|
||||
|
||||
users = 100;
|
||||
nixbld = 30000;
|
||||
|
@ -37,6 +37,7 @@
|
||||
./services/mail/postfix.nix
|
||||
./services/misc/autofs.nix
|
||||
./services/misc/disnix.nix
|
||||
./services/misc/gpsd.nix
|
||||
./services/misc/nix-daemon.nix
|
||||
./services/misc/nixos-manual.nix
|
||||
./services/misc/rogue.nix
|
||||
|
@ -1,3 +1,7 @@
|
||||
if [ -n "$NOSYSBASHRC" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Initialise a bunch of environment variables.
|
||||
export PATH=/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin
|
||||
export LD_LIBRARY_PATH=/var/run/opengl-driver/lib
|
||||
|
108
modules/services/misc/gpsd.nix
Normal file
108
modules/services/misc/gpsd.nix
Normal file
@ -0,0 +1,108 @@
|
||||
{pkgs, config, ...}:
|
||||
|
||||
###### interface
|
||||
let
|
||||
inherit (pkgs.lib) mkOption mkIf;
|
||||
|
||||
uid = (import ../system/ids.nix).uids.gpsd;
|
||||
gid = (import ../system/ids.nix).gids.gpsd;
|
||||
|
||||
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.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
###### implementation
|
||||
mkIf config.services.gpsd.enable {
|
||||
require = [
|
||||
options
|
||||
];
|
||||
|
||||
users = {
|
||||
extraUsers = [
|
||||
{ name = "gpsd";
|
||||
inherit uid;
|
||||
description = "gpsd daemon user";
|
||||
home = "/var/empty";
|
||||
}
|
||||
];
|
||||
|
||||
extraGroups = [
|
||||
{ name = "gpsd";
|
||||
inherit gid;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
services =
|
||||
let cfg = config.services.gpsd; in {
|
||||
extraJobs = [{
|
||||
name = "gpsd";
|
||||
|
||||
job =
|
||||
let gpsd = pkgs.gpsd;
|
||||
in ''
|
||||
description "GPSD daemon"
|
||||
|
||||
start on network-interfaces/started
|
||||
stop on network-interfaces/stop
|
||||
|
||||
respawn ${gpsd}/sbin/gpsd -D "${toString cfg.debugLevel}" \
|
||||
-S "${toString cfg.port}" \
|
||||
${if cfg.readonly then "-b" else ""} \
|
||||
"${cfg.device}"
|
||||
'';
|
||||
}];
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user