diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-01-11 11:38:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-11 11:38:53 +0100 |
commit | 7480f2bf20479641ec010153c12842c7cbf26789 (patch) | |
tree | a4fdc6f60d394028bef00a3ca5b9462242b998c0 | |
parent | fdcd62eec59485665b919c048874de05235b5971 (diff) | |
parent | 1db3f84baccc30ac38227c1f7edc3bfbc8e5ff5b (diff) |
Merge pull request #4435 from DanilaFe/flake-input-types
Allow Flake inputs to accept boolean and integer attributes
-rw-r--r-- | src/libexpr/flake/flake.cc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index 4f021570c..61aeae543 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -120,11 +120,20 @@ static FlakeInput parseFlakeInput(EvalState & state, expectType(state, nString, *attr.value, *attr.pos); input.follows = parseInputPath(attr.value->string.s); } else { - if (attr.value->type() == nString) - attrs.emplace(attr.name, attr.value->string.s); - else - throw TypeError("flake input attribute '%s' is %s while a string is expected", - attr.name, showType(*attr.value)); + switch (attr.value->type()) { + case nString: + attrs.emplace(attr.name, attr.value->string.s); + break; + case nBool: + attrs.emplace(attr.name, Explicit<bool> { attr.value->boolean }); + break; + case nInt: + attrs.emplace(attr.name, attr.value->integer); + break; + default: + throw TypeError("flake input attribute '%s' is %s while a string, Boolean, or integer is expected", + attr.name, showType(*attr.value)); + } } } catch (Error & e) { e.addTrace(*attr.pos, hintfmt("in flake attribute '%s'", attr.name)); |