From 23c7c10f5a5ed83dca001d7382e5b89981277f8c Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 6 Feb 2016 15:11:30 +0100 Subject: krebs.retiolum.hosts: change type to attrsOf host --- krebs/4lib/types.nix | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'krebs/4lib/types.nix') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index c596d0f9..6c396a13 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -119,16 +119,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; -- cgit v1.2.3 From 29746aec06b7d42d3c87245f6f14f048234251e4 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 6 Feb 2016 18:54:01 +0100 Subject: krebs.{backup.plans,hosts,users}.*.name: add default value --- krebs/4lib/types.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'krebs/4lib/types.nix') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index 6c396a13..2907a413 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -10,6 +10,7 @@ types // rec { options = { name = mkOption { type = label; + default = config._module.args.name; }; dc = mkOption { type = label; @@ -155,19 +156,20 @@ types // rec { merge = mergeOneOption; }; - user = submodule { + user = submodule ({ config, ... }: { options = { mail = mkOption { type = str; # TODO retiolum mail address }; name = mkOption { type = str; # TODO + default = config._module.args.name; }; pubkey = mkOption { type = str; }; }; - }; + }); # TODO addr = str; -- cgit v1.2.3 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(-) (limited to 'krebs/4lib/types.nix') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index 2907a413..f9150379 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 From 52fd80748d95b522561a477a1869d6923516f633 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 7 Feb 2016 05:08:32 +0100 Subject: krebs.types.{hostname,label}: check RFC952 --- krebs/4lib/types.nix | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'krebs/4lib/types.nix') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index f9150379..52eb764e 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -175,8 +175,6 @@ types // rec { addr = str; addr4 = str; addr6 = str; - hostname = str; - label = str; krebs.file-location = types.submodule { options = { @@ -195,6 +193,22 @@ types // rec { }; }; + # RFC952, B. Lexical grammar, + hostname = mkOptionType { + name = "hostname"; + check = x: all label.check (splitString "." x); + merge = mergeOneOption; + }; + + # RFC952, B. Lexical grammar, + # 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"; -- cgit v1.2.3 From 7a9f130c1230faf9662000dbd9ba8f06170bf254 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 8 Feb 2016 03:21:01 +0100 Subject: krebs: rm types.host.dc --- krebs/4lib/types.nix | 3 --- 1 file changed, 3 deletions(-) (limited to 'krebs/4lib/types.nix') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index 52eb764e..873f3ddf 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -12,9 +12,6 @@ types // rec { type = label; default = config._module.args.name; }; - dc = mkOption { - type = label; - }; cores = mkOption { type = positive; }; -- cgit v1.2.3