Allow drawing paths per user
This commit is contained in:
parent
32904e238f
commit
599529fb03
2 changed files with 64 additions and 3 deletions
19
marker.nix
19
marker.nix
|
@ -13,10 +13,16 @@ let
|
|||
type = markerType;
|
||||
default = {};
|
||||
};
|
||||
|
||||
arrival = lib.mkOption {
|
||||
type = markerType;
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
departure.style.label = lib.mkDefault (firstUpperAlnum name);
|
||||
arrival.style.label = lib.mkDefault (firstUpperAlnum name);
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -69,6 +75,10 @@ let
|
|||
]);
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./path.nix
|
||||
];
|
||||
|
||||
options = {
|
||||
users = lib.mkOption {
|
||||
type = lib.types.attrsOf userType;
|
||||
|
@ -81,11 +91,17 @@ in
|
|||
|
||||
config = {
|
||||
users = {
|
||||
manuel.departure = {
|
||||
manuel = {
|
||||
departure = {
|
||||
location = "Switzerland";
|
||||
style.size = "small";
|
||||
};
|
||||
|
||||
arrival = {
|
||||
location = "Prague";
|
||||
};
|
||||
};
|
||||
|
||||
ganondorf.departure = {
|
||||
location = "Argentinia";
|
||||
|
||||
|
@ -101,6 +117,7 @@ in
|
|||
(
|
||||
lib.concatMap (user: [
|
||||
user.departure
|
||||
user.arrival
|
||||
]) (lib.attrValues config.users));
|
||||
|
||||
center = lib.mkIf
|
||||
|
|
44
path.nix
Normal file
44
path.nix
Normal file
|
@ -0,0 +1,44 @@
|
|||
{ lib, config, ... }:
|
||||
let
|
||||
pathType = lib.types.submodule {
|
||||
options = {
|
||||
locations = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
map.paths = lib.mkOption {
|
||||
type = lib.types.listOf pathType;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
map.paths = builtins.map (
|
||||
user: {
|
||||
locations = [
|
||||
user.departure.location
|
||||
user.arrival.location
|
||||
];
|
||||
}) (lib.filter (
|
||||
user:
|
||||
user.departure.location != null
|
||||
&& user.arrival.location != null
|
||||
) (lib.attrValues config.users));
|
||||
|
||||
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;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue