summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--krebs/4lib/types.nix18
1 files changed, 17 insertions, 1 deletions
diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix
index 2907a413a..f91503794 100644
--- a/krebs/4lib/types.nix
+++ b/krebs/4lib/types.nix
@@ -162,7 +162,7 @@ types // rec {
type = str; # TODO retiolum mail address
};
name = mkOption {
- type = str; # TODO
+ type = username;
default = config._module.args.name;
};
pubkey = mkOption {
@@ -194,4 +194,20 @@ types // rec {
};
};
};
+
+ # POSIX.1‐2013, 3.278 Portable Filename Character Set
+ filename = mkOptionType {
+ name = "POSIX filename";
+ check = let
+ filename-chars = stringToCharacters
+ "-.0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ in s: all (flip elem filename-chars) (stringToCharacters s);
+ merge = mergeOneOption;
+ };
+
+ # POSIX.1-2013, 3.431 User Name
+ username = mkOptionType {
+ name = "POSIX username";
+ check = s: filename.check s && substring 0 1 s != "-";
+ };
}