summaryrefslogtreecommitdiffstats
path: root/krebs/4lib/types.nix
diff options
context:
space:
mode:
Diffstat (limited to 'krebs/4lib/types.nix')
-rw-r--r--krebs/4lib/types.nix61
1 files changed, 46 insertions, 15 deletions
diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix
index c596d0f9d..873f3ddfb 100644
--- a/krebs/4lib/types.nix
+++ b/krebs/4lib/types.nix
@@ -10,9 +10,7 @@ types // rec {
options = {
name = mkOption {
type = label;
- };
- dc = mkOption {
- type = label;
+ default = config._module.args.name;
};
cores = mkOption {
type = positive;
@@ -119,16 +117,18 @@ types // rec {
default = {};
};
tinc = mkOption {
- type = let net-config = config; in nullOr (submodule ({ config, ... }: {
+ type = let net = config; in nullOr (submodule ({ config, ... }: {
options = {
config = mkOption {
type = str;
- default = ''
- ${optionalString (net-config.via != null)
- (concatMapStringsSep "\n" (a: "Address = ${a}") net-config.via.addrs)}
- ${concatMapStringsSep "\n" (a: "Subnet = ${a}") net-config.addrs}
- ${config.pubkey}
- '';
+ default = concatStringsSep "\n" (
+ (optionals (net.via != null)
+ (map (a: "Address = ${a}") net.via.addrs))
+ ++
+ (map (a: "Subnet = ${a}") net.addrs)
+ ++
+ [config.pubkey]
+ );
};
pubkey = mkOption {
type = str;
@@ -153,26 +153,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 = {
@@ -190,4 +189,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 != "-";
+ };
}
[cgit] Unable to lock slot /tmp/cgit/74100000.lock: No such file or directory (2)