46 lines
917 B
Nix
46 lines
917 B
Nix
{ lib, config, ... }:
|
|
let
|
|
markerType = lib.types.submodule {
|
|
options = {
|
|
location = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.str;
|
|
default = null;
|
|
};
|
|
};
|
|
};
|
|
in
|
|
{
|
|
options = {
|
|
map.markers = lib.mkOption {
|
|
type = lib.types.listOf markerType;
|
|
};
|
|
};
|
|
|
|
config = {
|
|
map = {
|
|
markers = [
|
|
{ location = "Switzerland"; }
|
|
{ location = "New York"; }
|
|
];
|
|
|
|
center = lib.mkIf
|
|
(lib.length config.map.markers >= 1)
|
|
null;
|
|
|
|
zoom = lib.mkIf
|
|
(lib.length config.map.markers >= 2)
|
|
null;
|
|
};
|
|
|
|
requestParams =
|
|
let
|
|
paramsForMarkers = builtins.map
|
|
(marker: "$(${config.scripts.geocode}/bin/geocode ${
|
|
lib.escapeShellArg marker.location})")
|
|
config.map.markers;
|
|
in [
|
|
"markers=\"${lib.concatStringsSep "|" paramsForMarkers}\""
|
|
];
|
|
};
|
|
}
|