geoclue: integrate ols/wigle as backend

the wigle API limits are *strict*. probably too strict to actually be useful
This commit is contained in:
Colin 2024-06-20 11:35:26 +00:00
parent 3cd97b522c
commit b0e184b0f0
4 changed files with 39 additions and 4 deletions

View File

@ -53,6 +53,7 @@
./gdb.nix
./gdbus.nix
./geary.nix
./geoclue-demo-agent.nix
./geoclue2
./git.nix
./gnome-clocks.nix

View File

@ -0,0 +1,16 @@
{ config, pkgs, ... }:
{
sane.programs.geoclue-demo-agent = {
packageUnwrapped = pkgs.linkFarm "geoclue-demo-agent" [{
# bring the demo agent into a `bin/` directory so it can be invokable via PATH
name = "bin/geoclue-demo-agent";
path = "${config.sane.programs.geoclue2.packageUnwrapped}/libexec/geoclue-2.0/demos/agent";
}];
services.geoclue-agent = {
description = "geoclue 'demo' agent";
command = "geoclue-demo-agent";
partOf = [ "graphical-session" ];
};
};
}

View File

@ -1,11 +1,18 @@
# geoclue location services daemon.
#
# HOW TO TEST (hopefully):
# HOW TO TEST:
# - just invoke `where-am-i`: it should output the current latitude/longitude.
## more manual testing:
# - build `geoclue2-with-demo-agent`
# - run the service: `systemctl start geoclue` or "${geoclue2-with-demo-agent}/libexec/geoclue"
# - run "${geoclue2-with-demo-agent}/libexec/geoclue-2.0/demos/agent"
# - keep this running in the background
# - run "${geoclue2-with-demo-agent}/libexec/geoclue-2.0/demos/where-am-i"
#
# DATA FLOW:
# - geoclue2 does http calls into local `ols`, which either hits the local disk or queries https://wigle.net.
# - geoclue users like gnome-maps somehow depend on an "agent",
# a user service which launches the geoclue system service on-demand (via dbus activation).
{ config, lib, pkgs, ... }:
let
cfg = config.sane.programs.geoclue2;
@ -16,7 +23,9 @@ in
# packageUnwrapped = pkgs.geoclue2.override { withDemoAgent = true; };
packageUnwrapped = pkgs.geoclue2-with-demo-agent;
suggestedPrograms = [
"where-am-i"
"geoclue-demo-agent"
"ols" #< WiFi SSID -> lat/long lookups
"where-am-i" #< handy debugging/testing tool
];
};

View File

@ -1,7 +1,15 @@
# OLS: Offline Location Service: <https://codeberg.org/tpikonen/ols>
{ ... }:
# fields {wifi SSID,cell tower} -> lat/long queries from geoclue
# satisfies queries via https://wigle.net, by learning about map tiles
# and caching those on-disk so that repeat queries may be serviced offline.
#
# it listens on localhost:8088, and one can validate its operation with a query like (substitute macAddresses for something real):
# curl -d '{"wifiAccessPoints":[{"macAddress":"01:23:45:67:89:ab","signalStrength":-78},{"macAddress":"cd:ef:01:23:45:56","signalStrength":-76}]}' http://127.0.0.1:8088/v1/geolocate
{ pkgs, ... }:
{
sane.programs.ols = {
packageUnwrapped = pkgs.python3Packages.ols;
persist.byStore.private = [
".local/share/ols"
];
@ -10,7 +18,8 @@
services.ols = {
description = "ols: Offline Location Service";
command = "ols -d debug";
command = "ols";
partOf = [ "graphical-session" ];
};
};
}