2024-04-25 12:00:00 +00:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
{
|
2024-04-26 16:17:35 +00:00
|
|
|
imports = [
|
|
|
|
./marker.nix
|
|
|
|
];
|
|
|
|
|
2024-04-25 12:00:00 +00:00
|
|
|
options = {
|
2024-04-26 06:28:25 +00:00
|
|
|
scripts = {
|
|
|
|
output = lib.mkOption {
|
|
|
|
type = lib.types.package;
|
|
|
|
};
|
|
|
|
|
|
|
|
geocode = lib.mkOption {
|
|
|
|
type = lib.types.package;
|
|
|
|
};
|
2024-04-25 12:00:00 +00:00
|
|
|
};
|
|
|
|
|
2024-04-26 05:40:24 +00:00
|
|
|
map = {
|
|
|
|
zoom = lib.mkOption {
|
|
|
|
type = lib.types.nullOr lib.types.int;
|
|
|
|
default = 2;
|
|
|
|
};
|
2024-04-26 06:28:25 +00:00
|
|
|
|
|
|
|
center = lib.mkOption {
|
|
|
|
type = lib.types.nullOr lib.types.str;
|
|
|
|
default = "Switzerland";
|
|
|
|
};
|
2024-04-26 05:40:24 +00:00
|
|
|
};
|
|
|
|
|
2024-04-25 12:00:00 +00:00
|
|
|
requestParams = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
2024-04-26 06:28:25 +00:00
|
|
|
scripts = {
|
|
|
|
output = pkgs.writeShellApplication {
|
|
|
|
name = "map";
|
2024-04-26 05:40:24 +00:00
|
|
|
|
2024-04-26 06:28:25 +00:00
|
|
|
runtimeInputs = with pkgs; [
|
|
|
|
curl
|
|
|
|
imagemagick
|
|
|
|
];
|
2024-04-25 12:00:00 +00:00
|
|
|
|
2024-04-26 06:28:25 +00:00
|
|
|
text = ''
|
|
|
|
convert <(${./map} ${lib.concatStringsSep " " config.requestParams}) sixel:-
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
geocode = pkgs.writeShellApplication {
|
|
|
|
name = "geocode";
|
|
|
|
|
|
|
|
runtimeInputs = with pkgs; [
|
|
|
|
curl
|
|
|
|
jq
|
|
|
|
];
|
|
|
|
|
|
|
|
text = ''exec ${./geocode} "$@"'';
|
|
|
|
};
|
2024-04-25 12:00:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
requestParams = [
|
|
|
|
"size=640x300"
|
|
|
|
"scale=2"
|
2024-04-26 05:40:24 +00:00
|
|
|
(lib.mkIf (config.map.zoom != null)
|
|
|
|
"zoom=${toString config.map.zoom}")
|
2024-04-26 06:28:25 +00:00
|
|
|
(lib.mkIf (config.map.center != null)
|
|
|
|
"center=\"${config.scripts.geocode}/bin/geocode ${
|
|
|
|
lib.escapeShellArg config.map.center
|
|
|
|
}\"")
|
2024-04-25 12:00:00 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|