nix-da/options/meta.nix

28 lines
678 B
Nix

{ lib, ... }:
let
inherit (lib) mkOption stringLength;
inherit (lib.types) str strMatching;
validateUserName =
x:
assert (
stringLength x < 32 || abort "Username '${x}' is longer than 31 characters which is not allowed!"
);
x;
in
{
options.modules.meta = {
hostname = mkOption {
type = strMatching "^[[:alnum:]]([[:alnum:]_-]{0,61}[[:alnum:]])?$";
default = "";
description = "The system's hostname.";
};
username = mkOption {
default = "";
type = str;
apply = validateUserName;
# Should handle multiple users one day? maybe...
description = "This system's primary user.";
};
};
}