Skip to content

Commit

Permalink
tutorial: Fix the markers to build and concatenate (#816)
Browse files Browse the repository at this point in the history
The current code has a number of issues.

1. realising the code results in:

``
markers=$(geocode 'New York') size=640x640 scale=2 zoom=7 ...
        ^-------------------^ SC2046 (warning): Quote this to prevent
        word splitting.
``

2.
``
$(geocode ${lib.escapeShellArg marker.location})"
``

Assumes that geocode has been added to the PATH so replace with

``
${config.scripts.geocode}/bin/geocode
``

as per previous examples.

3.
``
  in "markers=${ lib.concatStringsSep "\\|" attributes}";
in builtins.map paramForMarker config.map.markers;
``

The ordering of this actually creates multiple ``[markers =]``
parameters and does not use the concatenation string to join the
attributes together (in effect there is only 1 attribute per call) to
map, and 1 new ``marker`` created.

Signed-off-by: Brian McGillion <[email protected]>
  • Loading branch information
brianmcgillion authored Nov 28, 2023
1 parent 791eb47 commit b584668
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions source/tutorials/module-system/module-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -602,18 +602,11 @@ To implement this behavior, add the following `config` block to `marker.nix`:
+ ];
+
+ requestParams = let
+ paramForMarker = marker:
+ let
+ attributes =
+ [
+ "$(geocode ${
+ lib.escapeShellArg marker.location
+ })"
+ ];
+ in "markers=${
+ lib.concatStringsSep "\\|" attributes
+ }";
+ in builtins.map paramForMarker config.map.markers;
+ paramForMarker =
+ builtins.map (marker: "$(${config.scripts.geocode}/bin/geocode ${
+ lib.escapeShellArg marker.location})") config.map.markers;
+ in [ "markers=\"${lib.concatStringsSep "|" paramForMarker}\"" ];
+ };
```

:::{warning}
Expand Down

0 comments on commit b584668

Please sign in to comment.