Skip to content

Commit 7480f2b

Browse files
authored
Merge pull request #4435 from DanilaFe/flake-input-types
Allow Flake inputs to accept boolean and integer attributes
2 parents fdcd62e + 1db3f84 commit 7480f2b

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/libexpr/flake/flake.cc

+14-5
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,20 @@ static FlakeInput parseFlakeInput(EvalState & state,
120120
expectType(state, nString, *attr.value, *attr.pos);
121121
input.follows = parseInputPath(attr.value->string.s);
122122
} else {
123-
if (attr.value->type() == nString)
124-
attrs.emplace(attr.name, attr.value->string.s);
125-
else
126-
throw TypeError("flake input attribute '%s' is %s while a string is expected",
127-
attr.name, showType(*attr.value));
123+
switch (attr.value->type()) {
124+
case nString:
125+
attrs.emplace(attr.name, attr.value->string.s);
126+
break;
127+
case nBool:
128+
attrs.emplace(attr.name, Explicit<bool> { attr.value->boolean });
129+
break;
130+
case nInt:
131+
attrs.emplace(attr.name, attr.value->integer);
132+
break;
133+
default:
134+
throw TypeError("flake input attribute '%s' is %s while a string, Boolean, or integer is expected",
135+
attr.name, showType(*attr.value));
136+
}
128137
}
129138
} catch (Error & e) {
130139
e.addTrace(*attr.pos, hintfmt("in flake attribute '%s'", attr.name));

0 commit comments

Comments
 (0)