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 = { arrival = {
location = "Prague"; location = "Prague";
}; };
pathStyle = {
weight = 10;
};
}; };
ganondorf.departure = { ganondorf.departure = {

View file

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