diff options
author | lassulus <lass@aidsballs.de> | 2016-02-16 17:15:00 +0100 |
---|---|---|
committer | lassulus <lass@aidsballs.de> | 2016-02-16 17:15:00 +0100 |
commit | 0b0b0d65ee05583529df831985580e392713d29a (patch) | |
tree | 7eb6799a996924d8e895c54633a47ea3d7a92a4c /krebs/4lib/types.nix | |
parent | 3d30e9cc9014ec6189410944015d3cd7d5ca95a6 (diff) | |
parent | b7a92f63884af00eb0243ec9328be689a6c9b845 (diff) |
Merge remote-tracking branch 'cd/master'
Diffstat (limited to 'krebs/4lib/types.nix')
-rw-r--r-- | krebs/4lib/types.nix | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index 6c396a132..d0a537467 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -10,15 +10,14 @@ types // rec { options = { name = mkOption { type = label; - }; - dc = mkOption { - type = label; + default = config._module.args.name; }; cores = mkOption { type = positive; }; nets = mkOption { type = attrsOf net; + default = {}; }; extraZones = mkOption { @@ -155,26 +154,25 @@ types // rec { merge = mergeOneOption; }; - user = submodule { + user = submodule ({ config, ... }: { options = { mail = mkOption { type = str; # TODO retiolum mail address }; name = mkOption { - type = str; # TODO + type = username; + default = config._module.args.name; }; pubkey = mkOption { type = str; }; }; - }; + }); # TODO addr = str; addr4 = str; addr6 = str; - hostname = str; - label = str; krebs.file-location = types.submodule { options = { @@ -192,4 +190,36 @@ types // rec { }; }; }; + + # RFC952, B. Lexical grammar, <hname> + hostname = mkOptionType { + name = "hostname"; + check = x: all label.check (splitString "." x); + merge = mergeOneOption; + }; + + # RFC952, B. Lexical grammar, <name> + # RFC1123, 2.1 Host Names and Numbers + label = mkOptionType { + name = "label"; + # TODO case-insensitive labels + check = x: match "[0-9A-Za-z]([0-9A-Za-z-]*[0-9A-Za-z])?" x != null; + merge = mergeOneOption; + }; + + # 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 != "-"; + }; } |