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; };