aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorDanila Fedorin <danila.fedorin@gmail.com>2021-01-08 01:53:57 +0000
committerDanila Fedorin <danila.fedorin@gmail.com>2021-01-08 01:53:57 +0000
commit93f1678ec60bcacfcc857f361b5f63e37c498eb4 (patch)
treec4cf9739729b86b5ba39bd1e7768dd132fc380dc /src/libexpr
parent920e6a6920fa0ae82150bb2b0c210a03ccf5919b (diff)
Allow Flake inputs to accept boolean and integer attributes
I believe that this makes it possible to do things like Git inputs with submodules, but it also likely applies to other input types from libfetchers.
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/flake/flake.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc
index 4f021570c..41c93bcaa 100644
--- a/src/libexpr/flake/flake.cc
+++ b/src/libexpr/flake/flake.cc
@@ -120,11 +120,16 @@ 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)
+ 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",
+ } else if (attr.value->type() == nBool) {
+ attrs.emplace(attr.name, Explicit<bool>{ attr.value->boolean });
+ } else if (attr.value->type() == nInt) {
+ attrs.emplace(attr.name, attr.value->integer);
+ } else {
+ 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));