NixTutorial/marker.nix

38 lines
751 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"; }
];
};
requestParams =
let
paramsForMarkers = builtins.map
(marker: "$(${config.scripts.geocode}/bin/geocode ${
lib.escapeShellArg marker.location})")
config.map.markers;
in [
"markers=\"${lib.concatStringsSep "|" paramsForMarkers}\""
];
};
}