From 434420ce7a5b153f8d2a0337f530728ac49779ba Mon Sep 17 00:00:00 2001 From: Brian McGillion Date: Wed, 29 Nov 2023 11:31:49 +0400 Subject: [PATCH 1/4] tutorial: Propagate previous geocode changes Propagate the changes made in a previous code snippet to this code snippet. Primarily fixing the poorly referenced ``${geocode``. Signed-off-by: Brian McGillion --- .../tutorials/module-system/module-system.md | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/source/tutorials/module-system/module-system.md b/source/tutorials/module-system/module-system.md index 9daa72f9a..affcd2121 100644 --- a/source/tutorials/module-system/module-system.md +++ b/source/tutorials/module-system/module-system.md @@ -742,20 +742,23 @@ In the `paramForMarker` function: ```{code-block} diff :caption: marker.nix - paramForMarker = marker: - let - attributes = -- [ -+ lib.optional -+ (marker.style.label != null) -+ "label:${marker.style.label}" + requestParams = let ++ paramForMarker = marker: ++ let ++ attributes = ++ lib.optional (marker.style.label != null) ++ "label:${marker.style.label}" + ++ [ - "$(geocode ${ - lib.escapeShellArg marker.location - })" ++ "$(${config.scripts.geocode}/bin/geocode ${ ++ lib.escapeShellArg marker.location ++ })" ++ ]; ++ in "markers=\"${lib.concatStringsSep "|" attributes}\""; ++ in ++ builtins.map paramForMarker config.map.markers; ``` -Here, the label for each `marker` is only propagated to the CLI parameters if `marker.style.label` is set. +Notice here how we now create a unique `marker` for each user by concatenating the `label` and `location` attributes together, and assigning them to the `requestParams`. The label for each `marker` is only propagated to the CLI parameters if `marker.style.label` is set. ## Functions as submodule arguments @@ -876,7 +879,7 @@ Now add an entry to the `paramForMarker` list which makes use of the new option: "label:${marker.style.label}" ++ [ + "color:${marker.style.color}" - "$(geocode ${ + "$(${config.scripts.geocode}/bin/geocode ${ lib.escapeShellArg marker.location })" ``` @@ -929,7 +932,7 @@ Finally, add another `lib.optional` call to the `attributes` string, making use + "size:${size}" ++ [ "color:${marker.style.color}" - "$(geocode ${ + "$(${config.scripts.geocode}/bin/geocode ${ ``` ## The `pathType` submodule From 72079246db86baa32d31964b8c5494c5a8b50088 Mon Sep 17 00:00:00 2001 From: Brian McGillion Date: Wed, 29 Nov 2023 16:59:25 +0400 Subject: [PATCH 2/4] tutorial: Fix requestParams for path.nix Adjust the functionality to reference geocode correctly and also to make sure of the correct escaping formats. Signed-off-by: Brian McGillion --- source/tutorials/module-system/module-system.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/source/tutorials/module-system/module-system.md b/source/tutorials/module-system/module-system.md index affcd2121..54d09f24e 100644 --- a/source/tutorials/module-system/module-system.md +++ b/source/tutorials/module-system/module-system.md @@ -966,15 +966,16 @@ in { config = { requestParams = let attrForLocation = loc: - "$(geocode ${lib.escapeShellArg loc})"; + "$(${config.scripts.geocode}/bin/geocode ${ + lib.escapeShellArg loc + })"; paramForPath = path: let attributes = builtins.map attrForLocation path.locations; - in "path=${ - lib.concatStringsSep "\\|" attributes - }"; - in builtins.map paramForPath config.map.paths; + in "path=\"${lib.concatStringsSep "|" attributes}\""; + in + builtins.map paramForPath config.map.paths; }; } ``` @@ -1130,9 +1131,7 @@ Finally, update the `attributes` list in `paramForPath`: + "weight:${toString path.style.weight}" + ] + ++ builtins.map attrForLocation path.locations; - in "path=${ - lib.concatStringsSep "\\|" attributes - }"; + in "path=\"${lib.concatStringsSep "|" attributes}\""; ``` ## The `pathStyle` submodule From 303425a05d2991dbe4473bb2602aab942849a30c Mon Sep 17 00:00:00 2001 From: Brian McGillion Date: Wed, 29 Nov 2023 22:04:00 +0400 Subject: [PATCH 3/4] fixup: source/tutorials/module-system/module-system.md Co-authored-by: Valentin Gagarin --- source/tutorials/module-system/module-system.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/tutorials/module-system/module-system.md b/source/tutorials/module-system/module-system.md index 54d09f24e..40473edbc 100644 --- a/source/tutorials/module-system/module-system.md +++ b/source/tutorials/module-system/module-system.md @@ -758,7 +758,8 @@ In the `paramForMarker` function: + builtins.map paramForMarker config.map.markers; ``` -Notice here how we now create a unique `marker` for each user by concatenating the `label` and `location` attributes together, and assigning them to the `requestParams`. The label for each `marker` is only propagated to the CLI parameters if `marker.style.label` is set. +Note how we now create a unique `marker` for each user by concatenating the `label` and `location` attributes together, and assigning them to the `requestParams`. +The label for each `marker` is only propagated to the CLI parameters if `marker.style.label` is set. ## Functions as submodule arguments From a06a70edaf081092c1fb5ac67866798768098344 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Fri, 1 Dec 2023 23:49:01 +0100 Subject: [PATCH 4/4] fix formatting --- .../tutorials/module-system/module-system.md | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/source/tutorials/module-system/module-system.md b/source/tutorials/module-system/module-system.md index 40473edbc..45c88ed3d 100644 --- a/source/tutorials/module-system/module-system.md +++ b/source/tutorials/module-system/module-system.md @@ -957,25 +957,25 @@ let }; }; }; -in { +in +{ options = { map.paths = lib.mkOption { type = lib.types.listOf pathType; }; }; - config = { - requestParams = let - attrForLocation = loc: - "$(${config.scripts.geocode}/bin/geocode ${ - lib.escapeShellArg loc - })"; - paramForPath = path: - let - attributes = - builtins.map attrForLocation path.locations; - in "path=\"${lib.concatStringsSep "|" attributes}\""; - in + requestParams = + let + attrForLocation = loc: + "$(${config.scripts.geocode}/bin/geocode ${lib.escapeShellArg loc})"; + paramForPath = path: + let + attributes = + builtins.map attrForLocation path.locations; + in + ''path="${lib.concatStringsSep "|" attributes}"''; + in builtins.map paramForPath config.map.paths; }; }