From 30306159af3aac4f04db60f27637480bbecaaa1d Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 6 Feb 2016 19:37:14 +0100 Subject: add krebs.types.{filename,username} --- krebs/4lib/types.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 != "-"; + }; } -- cgit v1.2.3