summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--krebs/4lib/default.nix10
1 files changed, 10 insertions, 0 deletions
diff --git a/krebs/4lib/default.nix b/krebs/4lib/default.nix
index bfe8c581c..da936fad6 100644
--- a/krebs/4lib/default.nix
+++ b/krebs/4lib/default.nix
@@ -15,6 +15,16 @@ let out = rec {
addNames = mapAttrs addName;
+ guard = spec@{ type, value, ... }:
+ assert isOptionType type;
+ if type.check value
+ then value
+ else throw (toString (filter isString [
+ "argument"
+ (if spec ? name then "‘${spec.name}’" else null)
+ "is not a ${type.name}"
+ ]));
+
types = import ./types.nix {
inherit config;
lib = lib // { inherit genid optionalTrace; };