summaryrefslogtreecommitdiffstats
path: root/krebs/4lib
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2016-02-06 19:37:14 +0100
committertv <tv@krebsco.de>2016-02-06 19:42:36 +0100
commit30306159af3aac4f04db60f27637480bbecaaa1d (patch)
treec84da502f459e5f71a563f046b1c69cc91e01f8b /krebs/4lib
parent29746aec06b7d42d3c87245f6f14f048234251e4 (diff)
add krebs.types.{filename,username}
Diffstat (limited to 'krebs/4lib')
-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 != "-";
+ };
}