summaryrefslogtreecommitdiffstats
path: root/krebs/4lib
diff options
context:
space:
mode:
authorlassulus <lass@aidsballs.de>2016-06-12 21:37:27 +0200
committerlassulus <lass@aidsballs.de>2016-06-12 21:37:27 +0200
commit4e001014c925288834a31ecf14345b34c1e7e212 (patch)
tree876860b97bbbc82108a74897834d67e05a21df49 /krebs/4lib
parent5dfc8d41d91fd6a48fb55e34e2b12d2012d37a38 (diff)
parentac3b87b9a62929a81d2a275b808681352cc3c10e (diff)
Merge remote-tracking branch 'cd/master'
Diffstat (limited to 'krebs/4lib')
-rw-r--r--krebs/4lib/default.nix2
-rw-r--r--krebs/4lib/types.nix27
2 files changed, 18 insertions, 11 deletions
diff --git a/krebs/4lib/default.nix b/krebs/4lib/default.nix
index 585bd313f..bfe8c581c 100644
--- a/krebs/4lib/default.nix
+++ b/krebs/4lib/default.nix
@@ -41,8 +41,6 @@ let out = rec {
mapAttrs (name: _: path + "/${name}")
(filterAttrs (_: eq "directory") (readDir path));
- getAttrDef = name: set: set.${name} or set.default or null;
- mapAttrValues = f: mapAttrs (_: f);
setAttr = name: value: set: set // { ${name} = value; };
optionalTrace = c: msg: x: if c then trace msg x else x;
diff --git a/krebs/4lib/types.nix b/krebs/4lib/types.nix
index 66191d0b3..4742877a7 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; };
@@ -199,8 +205,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 {
@@ -318,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._])[0-9A-Za-z._-]*" x != null;
merge = mergeOneOption;
};
@@ -330,19 +334,24 @@ types // rec {
# TODO two slashes
absolute-pathname = mkOptionType {
name = "POSIX absolute pathname";
- check = 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;
};
# POSIX.1‐2013, 3.267 Pathname
# 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;
};
# POSIX.1-2013, 3.431 User Name
username = mkOptionType {
name = "POSIX username";
- check = s: filename.check s && substring 0 1 s != "-";
+ check = filename.check;
+ merge = mergeOneOption;
};
}