Allow users to set path styles

This commit is contained in:
Manuel Thalmann 2024-04-28 21:13:23 +02:00
parent 599529fb03
commit a8a685ccf3
2 changed files with 35 additions and 1 deletions

View file

@ -100,6 +100,10 @@ in
arrival = {
location = "Prague";
};
pathStyle = {
weight = 10;
};
};
ganondorf.departure = {

View file

@ -5,11 +5,35 @@ let
locations = lib.mkOption {
type = lib.types.listOf lib.types.str;
};
style = lib.mkOption {
type = pathStyleType;
default = {};
};
};
};
pathStyleType = lib.types.submodule {
options = {
weight = lib.mkOption {
type = lib.types.ints.between 1 20;
default = 5;
};
};
};
in
{
options = {
users = lib.mkOption {
type = lib.types.attrsOf (
lib.types.submodule {
options.pathStyle = lib.mkOption {
type = pathStyleType;
default = {};
};
});
};
map.paths = lib.mkOption {
type = lib.types.listOf pathType;
};
@ -22,6 +46,8 @@ in
user.departure.location
user.arrival.location
];
style = user.pathStyle;
}) (lib.filter (
user:
user.departure.location != null
@ -35,7 +61,11 @@ in
paramForPath =
path:
let
attributes = builtins.map attrForLocation path.locations;
attributes =
[
"weight:${toString path.style.weight}"
]
++ builtins.map attrForLocation path.locations;
in
''path="${lib.concatStringsSep "|" attributes}"'';
in