traccar: init at 6.5
This commit is contained in:
parent
7cc48215b1
commit
9293bc7d55
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
- [Omnom](https://github.com/asciimoo/omnom), a webpage bookmarking and snapshotting service. Available as [services.omnom](options.html#opt-services.omnom.enable).
|
- [Omnom](https://github.com/asciimoo/omnom), a webpage bookmarking and snapshotting service. Available as [services.omnom](options.html#opt-services.omnom.enable).
|
||||||
|
|
||||||
|
- [Traccar](https://www.traccar.org/), a modern GPS Tracking Platform. Available as [services.traccar](#opt-services.traccar.enable).
|
||||||
|
|
||||||
- [Amazon CloudWatch Agent](https://github.com/aws/amazon-cloudwatch-agent), the official telemetry collector for AWS CloudWatch and AWS X-Ray. Available as [services.amazon-cloudwatch-agent](#opt-services.amazon-cloudwatch-agent.enable).
|
- [Amazon CloudWatch Agent](https://github.com/aws/amazon-cloudwatch-agent), the official telemetry collector for AWS CloudWatch and AWS X-Ray. Available as [services.amazon-cloudwatch-agent](#opt-services.amazon-cloudwatch-agent.enable).
|
||||||
|
|
||||||
- [agorakit](https://github.com/agorakit/agorakit), an organization tool for citizens' collectives. Available with [services.agorakit](#opt-services.agorakit.enable).
|
- [agorakit](https://github.com/agorakit/agorakit), an organization tool for citizens' collectives. Available with [services.agorakit](#opt-services.agorakit.enable).
|
||||||
|
|||||||
@ -947,6 +947,7 @@
|
|||||||
./services/monitoring/telegraf.nix
|
./services/monitoring/telegraf.nix
|
||||||
./services/monitoring/thanos.nix
|
./services/monitoring/thanos.nix
|
||||||
./services/monitoring/todesk.nix
|
./services/monitoring/todesk.nix
|
||||||
|
./services/monitoring/traccar.nix
|
||||||
./services/monitoring/tremor-rs.nix
|
./services/monitoring/tremor-rs.nix
|
||||||
./services/monitoring/tuptime.nix
|
./services/monitoring/tuptime.nix
|
||||||
./services/monitoring/unpoller.nix
|
./services/monitoring/unpoller.nix
|
||||||
|
|||||||
125
nixos/modules/services/monitoring/traccar.nix
Normal file
125
nixos/modules/services/monitoring/traccar.nix
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.services.traccar;
|
||||||
|
stateDirectory = "/var/lib/traccar";
|
||||||
|
configFilePath = "${stateDirectory}/config.xml";
|
||||||
|
expandCamelCase = lib.replaceStrings lib.upperChars (map (s: ".${s}") lib.lowerChars);
|
||||||
|
mkConfigEntry = key: value: "<entry key='${expandCamelCase key}'>${value}</entry>";
|
||||||
|
mkConfig =
|
||||||
|
configurationOptions:
|
||||||
|
pkgs.writeText "traccar.xml" ''
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<!DOCTYPE properties SYSTEM 'http://java.sun.com/dtd/properties.dtd'>
|
||||||
|
<properties>
|
||||||
|
${builtins.concatStringsSep "\n" (lib.mapAttrsToList mkConfigEntry configurationOptions)}
|
||||||
|
</properties>
|
||||||
|
'';
|
||||||
|
|
||||||
|
defaultConfig = {
|
||||||
|
databaseDriver = "org.h2.Driver";
|
||||||
|
databasePassword = "";
|
||||||
|
databaseUrl = "jdbc:h2:${stateDirectory}/traccar";
|
||||||
|
databaseUser = "sa";
|
||||||
|
loggerConsole = "true";
|
||||||
|
mediaPath = "${stateDirectory}/media";
|
||||||
|
templatesRoot = "${stateDirectory}/templates";
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.services.traccar = {
|
||||||
|
enable = lib.mkEnableOption "Traccar, an open source GPS tracking system";
|
||||||
|
settings = lib.mkOption {
|
||||||
|
apply = lib.recursiveUpdate defaultConfig;
|
||||||
|
default = defaultConfig;
|
||||||
|
description = ''
|
||||||
|
{file}`config.xml` configuration as a Nix attribute set.
|
||||||
|
Attribute names are translated from camelCase to dot-separated strings. For instance:
|
||||||
|
{option}`mailSmtpPort = "25"`
|
||||||
|
would result in the following configuration property:
|
||||||
|
`<entry key='mail.smtp.port'>25</entry>`
|
||||||
|
Configuration options should match those described in
|
||||||
|
[Traccar - Configuration File](https://www.traccar.org/configuration-file/).
|
||||||
|
Secret tokens should be specified using {option}`environmentFile`
|
||||||
|
instead of this world-readable attribute set.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
environmentFile = lib.mkOption {
|
||||||
|
type = lib.types.nullOr lib.types.path;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
File containing environment variables to substitute in the configuration before starting Traccar.
|
||||||
|
|
||||||
|
Can be used for storing the secrets without making them available in the world-readable Nix store.
|
||||||
|
|
||||||
|
For example, you can set {option}`services.traccar.settings.databasePassword = "$TRACCAR_DB_PASSWORD"`
|
||||||
|
and then specify `TRACCAR_DB_PASSWORD="<secret>"` in the environment file.
|
||||||
|
This value will get substituted in the configuration file.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config =
|
||||||
|
let
|
||||||
|
configuration = mkConfig cfg.settings;
|
||||||
|
in
|
||||||
|
lib.mkIf cfg.enable {
|
||||||
|
systemd.services.traccar = {
|
||||||
|
enable = true;
|
||||||
|
description = "Traccar";
|
||||||
|
|
||||||
|
after = [ "network-online.target" ];
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
wants = [ "network-online.target" ];
|
||||||
|
|
||||||
|
preStart = ''
|
||||||
|
# Copy new templates into our state directory.
|
||||||
|
cp -a --update=none ${pkgs.traccar}/templates ${stateDirectory}
|
||||||
|
test -f '${configFilePath}' && rm -f '${configFilePath}'
|
||||||
|
|
||||||
|
# Substitute the configFile from Envvars read from EnvironmentFile
|
||||||
|
old_umask=$(umask)
|
||||||
|
umask 0177
|
||||||
|
${lib.getExe pkgs.envsubst} \
|
||||||
|
-i ${configuration} \
|
||||||
|
-o ${configFilePath}
|
||||||
|
umask $old_umask
|
||||||
|
'';
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
DynamicUser = true;
|
||||||
|
EnvironmentFile = cfg.environmentFile;
|
||||||
|
ExecStart = "${lib.getExe pkgs.traccar} ${configFilePath}";
|
||||||
|
LockPersonality = true;
|
||||||
|
NoNewPrivileges = true;
|
||||||
|
PrivateDevices = true;
|
||||||
|
PrivateTmp = true;
|
||||||
|
PrivateUsers = true;
|
||||||
|
ProtectClock = true;
|
||||||
|
ProtectControlGroups = true;
|
||||||
|
ProtectHome = true;
|
||||||
|
ProtectHostname = true;
|
||||||
|
ProtectKernelLogs = true;
|
||||||
|
ProtectKernelModules = true;
|
||||||
|
ProtectKernelTunables = true;
|
||||||
|
ProtectSystem = "strict";
|
||||||
|
Restart = "on-failure";
|
||||||
|
RestartSec = 10;
|
||||||
|
RestrictRealtime = true;
|
||||||
|
RestrictSUIDSGID = true;
|
||||||
|
StateDirectory = "traccar";
|
||||||
|
SuccessExitStatus = 143;
|
||||||
|
Type = "simple";
|
||||||
|
# Set the working directory to traccar's package.
|
||||||
|
# Traccar only searches for the DB migrations relative to it's WorkingDirectory and nothing worked to
|
||||||
|
# work around this. To avoid copying the migrations over to the state directory, we use the package as
|
||||||
|
# WorkingDirectory.
|
||||||
|
WorkingDirectory = "${pkgs.traccar}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
43
pkgs/by-name/tr/traccar/package.nix
Normal file
43
pkgs/by-name/tr/traccar/package.nix
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
fetchzip,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
stdenvNoCC,
|
||||||
|
}:
|
||||||
|
stdenvNoCC.mkDerivation rec {
|
||||||
|
pname = "traccar";
|
||||||
|
version = "6.5";
|
||||||
|
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||||
|
|
||||||
|
src = fetchzip {
|
||||||
|
stripRoot = false;
|
||||||
|
url = "https://github.com/traccar/traccar/releases/download/v${version}/traccar-other-${version}.zip";
|
||||||
|
hash = "sha256-XCG3G24oe/qR6LiMJASb9STOnyTCtw+2HigaPawcQvU=";
|
||||||
|
};
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
for dir in lib schema templates web ; do
|
||||||
|
mkdir -p $out/$dir
|
||||||
|
cp -a $dir $out
|
||||||
|
done
|
||||||
|
|
||||||
|
mkdir -p $out/share/traccar
|
||||||
|
install -Dm644 tracker-server.jar $out
|
||||||
|
|
||||||
|
makeWrapper ${pkgs.openjdk}/bin/java $out/bin/traccar \
|
||||||
|
--add-flags "-jar $out/tracker-server.jar"
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "Open source GPS tracking system";
|
||||||
|
homepage = "https://www.traccar.org/";
|
||||||
|
sourceProvenance = with sourceTypes; [ binaryBytecode ];
|
||||||
|
license = licenses.asl20;
|
||||||
|
mainProgram = "traccar";
|
||||||
|
maintainers = with maintainers; [ frederictobiasc ];
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user