From 39ebd5001ebcbcc9d991784ec1ce6dd804dbdcd4 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 7 Jun 2016 02:15:58 +0200 Subject: getAttrDef: RIP --- krebs/4lib/types.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'krebs/4lib/types.nix') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index 66191d0b..f78d601e 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -199,8 +199,9 @@ types // rec { description = '' Set of user's PGP public keys. - Modules supporting PGP may use well-known key names to define option - defaults, e.g. using `getAttrDef well-known-name pubkeys`. + Modules supporting PGP may use well-known key names to define + default values for options, in which case the well-known name + should be documented in the respective option's description. ''; }; pubkey = mkOption { -- cgit v1.2.3 From 6fcc35afb0003f0885994b3c09e401f3178d7a08 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 7 Jun 2016 22:36:40 +0200 Subject: krebs types.uint: init --- krebs/4lib/types.nix | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'krebs/4lib/types.nix') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index f78d601e..d4d28bc7 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -154,6 +154,12 @@ types // rec { merge = mergeOneOption; }; + uint = mkOptionType { + name = "unsigned integer"; + check = x: isInt x && x >= 0; + merge = mergeOneOption; + }; + secret-file = submodule ({ config, ... }: { options = { path = mkOption { type = str; }; -- cgit v1.2.3 From 5e91e789b66350302b3a5f90843d4a10f4fd2c75 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 7 Jun 2016 23:22:12 +0200 Subject: krebs types.absolute-pathname: admit / --- krebs/4lib/types.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'krebs/4lib/types.nix') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index d4d28bc7..f65d5b68 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -337,7 +337,7 @@ types // rec { # TODO two slashes absolute-pathname = mkOptionType { name = "POSIX absolute pathname"; - check = s: pathname.check s && substring 0 1 s == "/"; + check = s: s == "/" || (pathname.check s && substring 0 1 s == "/"); }; # POSIX.1‐2013, 3.267 Pathname -- cgit v1.2.3 From c80aee7a0b5f3bc064e7f02d9c3d10dc83f1ce73 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 11 Jun 2016 16:11:22 +0200 Subject: krebs types.filename: admit --- krebs/4lib/types.nix | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'krebs/4lib/types.nix') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index f65d5b68..b048f48d 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -325,10 +325,7 @@ 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); + check = x: match "[0-9A-Za-z._-]+" x != null; merge = mergeOneOption; }; -- cgit v1.2.3 From cda4c2d96b70c296ad97e4d9118aa55ea7c3a594 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 11 Jun 2016 16:29:18 +0200 Subject: krebs types.filename: maximize strictness --- krebs/4lib/types.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'krebs/4lib/types.nix') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index b048f48d..628555a9 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -325,7 +325,7 @@ types // rec { # POSIX.1‐2013, 3.278 Portable Filename Character Set filename = mkOptionType { name = "POSIX filename"; - check = x: match "[0-9A-Za-z._-]+" x != null; + check = x: match "([0-9A-Za-z._])[0-9A-Za-z._-]*" x != null; merge = mergeOneOption; }; @@ -347,6 +347,6 @@ types // rec { # POSIX.1-2013, 3.431 User Name username = mkOptionType { name = "POSIX username"; - check = s: filename.check s && substring 0 1 s != "-"; + check = filename.check; }; } -- cgit v1.2.3 From 8353b1293e4e4c307e7b875a5449ac901a5afc7d Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 11 Jun 2016 16:36:42 +0200 Subject: krebs {{absolute-,}path,user}name: mergeOneOption --- krebs/4lib/types.nix | 3 +++ 1 file changed, 3 insertions(+) (limited to 'krebs/4lib/types.nix') diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix index 628555a9..678ae7a6 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -335,6 +335,7 @@ types // rec { absolute-pathname = mkOptionType { name = "POSIX absolute pathname"; check = s: s == "/" || (pathname.check s && substring 0 1 s == "/"); + merge = mergeOneOption; }; # POSIX.1‐2013, 3.267 Pathname @@ -342,11 +343,13 @@ types // rec { pathname = mkOptionType { name = "POSIX pathname"; check = s: isString s && all filename.check (splitString "/" s); + merge = mergeOneOption; }; # POSIX.1-2013, 3.431 User Name username = mkOptionType { name = "POSIX username"; check = filename.check; + merge = mergeOneOption; }; } -- cgit v1.2.3 From 29442eda7c864265ccf23df0b350572d5527dd86 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 12 Jun 2016 18:13:05 +0200 Subject: krebs {absolute,}-pathname: admit harder --- 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 678ae7a6..4742877a 100644 --- a/krebs/4lib/types.nix +++ b/krebs/4lib/types.nix @@ -334,7 +334,8 @@ types // rec { # TODO two slashes absolute-pathname = mkOptionType { name = "POSIX absolute pathname"; - check = s: s == "/" || (pathname.check s && substring 0 1 s == "/"); + check = x: let xs = splitString "/" x; xa = head xs; in + xa == "/" || (xa == "" && all filename.check (tail xs)); merge = mergeOneOption; }; @@ -342,7 +343,8 @@ types // rec { # TODO normalize slashes pathname = mkOptionType { name = "POSIX pathname"; - check = s: isString s && all filename.check (splitString "/" s); + check = x: let xs = splitString "/" x; in + all filename.check (if head xs == "" then tail xs else xs); merge = mergeOneOption; }; -- cgit v1.2.3