2024-04-26 16:17:35 +00:00
|
|
|
{ lib, config, ... }:
|
|
|
|
let
|
|
|
|
markerType = lib.types.submodule {
|
|
|
|
options = {
|
|
|
|
location = lib.mkOption {
|
|
|
|
type = lib.types.nullOr lib.types.str;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-04-26 22:14:19 +00:00
|
|
|
|
|
|
|
userType = lib.types.submodule {
|
|
|
|
options = {
|
|
|
|
departure = lib.mkOption {
|
|
|
|
type = markerType;
|
|
|
|
default = {};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-04-26 16:17:35 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
2024-04-26 22:14:19 +00:00
|
|
|
users = lib.mkOption {
|
|
|
|
type = lib.types.attrsOf userType;
|
|
|
|
};
|
|
|
|
|
2024-04-26 16:17:35 +00:00
|
|
|
map.markers = lib.mkOption {
|
|
|
|
type = lib.types.listOf markerType;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
2024-04-26 22:14:19 +00:00
|
|
|
users = {
|
|
|
|
manuel.departure.location = "Switzerland";
|
|
|
|
ganondorf.departure.location = "Argentinia";
|
|
|
|
};
|
|
|
|
|
2024-04-26 16:17:35 +00:00
|
|
|
map = {
|
2024-04-26 22:14:19 +00:00
|
|
|
markers = lib.filter
|
|
|
|
(marker: marker.location != null)
|
|
|
|
(
|
|
|
|
lib.concatMap (user: [
|
|
|
|
user.departure
|
|
|
|
]) (lib.attrValues config.users));
|
2024-04-26 16:21:21 +00:00
|
|
|
|
|
|
|
center = lib.mkIf
|
|
|
|
(lib.length config.map.markers >= 1)
|
|
|
|
null;
|
|
|
|
|
|
|
|
zoom = lib.mkIf
|
|
|
|
(lib.length config.map.markers >= 2)
|
|
|
|
null;
|
2024-04-26 16:17:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
requestParams =
|
|
|
|
let
|
|
|
|
paramsForMarkers = builtins.map
|
|
|
|
(marker: "$(${config.scripts.geocode}/bin/geocode ${
|
|
|
|
lib.escapeShellArg marker.location})")
|
|
|
|
config.map.markers;
|
|
|
|
in [
|
|
|
|
"markers=\"${lib.concatStringsSep "|" paramsForMarkers}\""
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|