From c9dd4abb28c7b35a20647d124126a23f2ce85734 Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Sat, 27 Apr 2024 00:30:42 +0200
Subject: [PATCH] Allow setting marker labels

---
 marker.nix | 38 +++++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)

diff --git a/marker.nix b/marker.nix
index 83db38a..1a69602 100644
--- a/marker.nix
+++ b/marker.nix
@@ -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;
   };
 }