Allow setting marker labels

This commit is contained in:
Manuel Thalmann 2024-04-27 00:30:42 +02:00
parent 16d97b8a29
commit c9dd4abb28

View file

@ -6,6 +6,12 @@ let
type = lib.types.nullOr lib.types.str;
default = null;
};
style.label = lib.mkOption {
type = lib.types.nullOr
(lib.types.strMatching "[0-9A-Z]");
default = null;
};
};
};
@ -31,8 +37,15 @@ in
config = {
users = {
manuel.departure.location = "Switzerland";
ganondorf.departure.location = "Argentinia";
manuel.departure = {
location = "Switzerland";
style.label = "M";
};
ganondorf.departure = {
location = "Argentinia";
style.label = "G";
};
};
map = {
@ -54,12 +67,19 @@ in
requestParams =
let
paramsForMarkers = builtins.map
(marker: "$(${config.scripts.geocode}/bin/geocode ${
lib.escapeShellArg marker.location})")
config.map.markers;
in [
"markers=\"${lib.concatStringsSep "|" paramsForMarkers}\""
];
paramForMarker =
marker:
let
attributes =
lib.optional (marker.style.label != null)
"label:${marker.style.label}"
++ [
"$(${config.scripts.geocode}/bin/geocode ${
lib.escapeShellArg marker.location
})"
];
in
"markers=\"${lib.concatStringsSep "|" attributes}\"";
in builtins.map paramForMarker config.map.markers;
};
}