Merge pull request #4435 from DanilaFe/flake-input-types

Allow Flake inputs to accept boolean and integer attributes
This commit is contained in:
Eelco Dolstra 2021-01-11 11:38:53 +01:00 committed by GitHub
commit 7480f2bf20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -120,11 +120,20 @@ static FlakeInput parseFlakeInput(EvalState & state,
expectType(state, nString, *attr.value, *attr.pos); expectType(state, nString, *attr.value, *attr.pos);
input.follows = parseInputPath(attr.value->string.s); input.follows = parseInputPath(attr.value->string.s);
} else { } else {
if (attr.value->type() == nString) switch (attr.value->type()) {
attrs.emplace(attr.name, attr.value->string.s); case nString:
else attrs.emplace(attr.name, attr.value->string.s);
throw TypeError("flake input attribute '%s' is %s while a string is expected", break;
attr.name, showType(*attr.value)); 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) { } catch (Error & e) {
e.addTrace(*attr.pos, hintfmt("in flake attribute '%s'", attr.name)); e.addTrace(*attr.pos, hintfmt("in flake attribute '%s'", attr.name));