Generate pin labels automatically

This commit is contained in:
Manuel Thalmann 2024-04-28 18:04:17 +02:00
parent c9dd4abb28
commit 6c134d9878

View file

@ -1,5 +1,25 @@
{ lib, config, ... }:
let
# Returns the uppercased first label or number of a string
firstUpperAlnum =
str:
lib.mapNullable
lib.head (builtins.match "[^A-Z0-9]*([A-Z0-9]).*" (lib.toUpper str));
userType = lib.types.submodule (
{ name, ... }: {
options = {
departure = lib.mkOption {
type = markerType;
default = {};
};
};
config = {
departure.style.label = lib.mkDefault (firstUpperAlnum name);
};
});
markerType = lib.types.submodule {
options = {
location = lib.mkOption {
@ -14,15 +34,6 @@ let
};
};
};
userType = lib.types.submodule {
options = {
departure = lib.mkOption {
type = markerType;
default = {};
};
};
};
in
{
options = {
@ -39,12 +50,10 @@ in
users = {
manuel.departure = {
location = "Switzerland";
style.label = "M";
};
ganondorf.departure = {
location = "Argentinia";
style.label = "G";
};
};