Compare commits
2 Commits
main
...
39a178d59b
| Author | SHA1 | Date | |
|---|---|---|---|
| 39a178d59b | |||
| 932c9c17f2 |
@@ -73,6 +73,8 @@
|
|||||||
./services/harmonia.nix
|
./services/harmonia.nix
|
||||||
|
|
||||||
./services/ddns-updater.nix
|
./services/ddns-updater.nix
|
||||||
|
|
||||||
|
./services/traccar.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
# Hosts entries for CI/CD deploy targets
|
# Hosts entries for CI/CD deploy targets
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ rec {
|
|||||||
port = 64738;
|
port = 64738;
|
||||||
proto = "both";
|
proto = "both";
|
||||||
};
|
};
|
||||||
|
traccar_tracking = {
|
||||||
|
port = 5056;
|
||||||
|
proto = "tcp";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Ports bound to localhost / VPN only. The flake asserts none of
|
# Ports bound to localhost / VPN only. The flake asserts none of
|
||||||
@@ -197,6 +201,10 @@ rec {
|
|||||||
port = 5500;
|
port = 5500;
|
||||||
proto = "tcp";
|
proto = "tcp";
|
||||||
};
|
};
|
||||||
|
traccar_web = {
|
||||||
|
port = 8082;
|
||||||
|
proto = "tcp";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -330,6 +338,10 @@ rec {
|
|||||||
dataDir = services_dir + "/trilium";
|
dataDir = services_dir + "/trilium";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
traccar = {
|
||||||
|
domain = "traccar.${https.domain}";
|
||||||
|
};
|
||||||
|
|
||||||
media = {
|
media = {
|
||||||
moviesDir = torrents_path + "/media/movies";
|
moviesDir = torrents_path + "/media/movies";
|
||||||
tvDir = torrents_path + "/media/tv";
|
tvDir = torrents_path + "/media/tv";
|
||||||
|
|||||||
74
services/traccar.nix
Normal file
74
services/traccar.nix
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
{
|
||||||
|
service_configs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
(lib.serviceMountWithZpool "traccar" service_configs.zpool_ssds [
|
||||||
|
"/var/lib/traccar"
|
||||||
|
])
|
||||||
|
(lib.serviceFilePerms "traccar" [
|
||||||
|
"Z /var/lib/traccar 0700 traccar traccar"
|
||||||
|
])
|
||||||
|
(lib.mkCaddyReverseProxy {
|
||||||
|
subdomain = "traccar";
|
||||||
|
port = service_configs.ports.private.traccar_web.port;
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
users.users.traccar = {
|
||||||
|
isSystemUser = true;
|
||||||
|
group = "traccar";
|
||||||
|
home = "/var/lib/traccar";
|
||||||
|
description = "Traccar GPS Tracking";
|
||||||
|
};
|
||||||
|
users.groups.traccar = { };
|
||||||
|
|
||||||
|
# PostgreSQL database (auto-created, peer auth via Unix socket)
|
||||||
|
services.postgresql = {
|
||||||
|
ensureDatabases = [ "traccar" ];
|
||||||
|
ensureUsers = [
|
||||||
|
{
|
||||||
|
name = "traccar";
|
||||||
|
ensureDBOwnership = true;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
services.traccar = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
web.port = toString service_configs.ports.private.traccar_web.port;
|
||||||
|
|
||||||
|
# PostgreSQL via Unix socket (peer auth, junixsocket is bundled)
|
||||||
|
database = {
|
||||||
|
driver = "org.postgresql.Driver";
|
||||||
|
url = "jdbc:postgresql:///traccar?socketFactory=org.newsclub.net.unix.AFUNIXSocketFactory$FactoryArg&socketFactoryArg=${service_configs.postgres.socket}/.s.PGSQL.5432";
|
||||||
|
user = "traccar";
|
||||||
|
password = "";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Only enable OsmAnd protocol (phone app). Prevents Traccar from
|
||||||
|
# opening 200+ default protocol ports that conflict with other services.
|
||||||
|
protocols.enable = "osmand";
|
||||||
|
osmand.port = toString service_configs.ports.public.traccar_tracking.port;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Disable DynamicUser so we can use peer auth with PostgreSQL
|
||||||
|
systemd.services.traccar = {
|
||||||
|
after = [ "postgresql.service" ];
|
||||||
|
requires = [ "postgresql.service" ];
|
||||||
|
serviceConfig = {
|
||||||
|
DynamicUser = lib.mkForce false;
|
||||||
|
User = "traccar";
|
||||||
|
Group = "traccar";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# OsmAnd tracking port must be reachable from the internet for the phone app
|
||||||
|
networking.firewall.allowedTCPPorts = [
|
||||||
|
service_configs.ports.public.traccar_tracking.port
|
||||||
|
];
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user