Allow the creation of location pins

This commit is contained in:
Manuel Thalmann 2024-04-26 18:17:35 +02:00
parent 33e2a7bf53
commit df9a9de068
2 changed files with 41 additions and 0 deletions

View file

@ -1,5 +1,9 @@
{ pkgs, lib, config, ... }:
{
imports = [
./marker.nix
];
options = {
scripts = {
output = lib.mkOption {

37
marker.nix Normal file
View file

@ -0,0 +1,37 @@
{ 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}\""
];
};
}