From df9a9de068a7b1ea3b40e536325478d5bb9c5757 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 26 Apr 2024 18:17:35 +0200 Subject: [PATCH] Allow the creation of location pins --- default.nix | 4 ++++ marker.nix | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 marker.nix diff --git a/default.nix b/default.nix index c1bcdec..d50bebb 100644 --- a/default.nix +++ b/default.nix @@ -1,5 +1,9 @@ { pkgs, lib, config, ... }: { + imports = [ + ./marker.nix + ]; + options = { scripts = { output = lib.mkOption { diff --git a/marker.nix b/marker.nix new file mode 100644 index 0000000..c9b64cb --- /dev/null +++ b/marker.nix @@ -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}\"" + ]; + }; +}