Merge pull request #5623 from yorickvP/fix-5621

flakes: fix boolean and int nixConfig values
This commit is contained in:
Théophane Hufschmitt 2021-12-14 10:35:37 +01:00 committed by GitHub
commit 8868da45a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 5 deletions

View file

@ -38,11 +38,11 @@ void ConfigFile::apply()
// FIXME: Move into libutil/config.cc. // FIXME: Move into libutil/config.cc.
std::string valueS; std::string valueS;
if (auto s = std::get_if<std::string>(&value)) if (auto* s = std::get_if<std::string>(&value))
valueS = *s; valueS = *s;
else if (auto n = std::get_if<int64_t>(&value)) else if (auto* n = std::get_if<int64_t>(&value))
valueS = fmt("%d", n); valueS = fmt("%d", *n);
else if (auto b = std::get_if<Explicit<bool>>(&value)) else if (auto* b = std::get_if<Explicit<bool>>(&value))
valueS = b->t ? "true" : "false"; valueS = b->t ? "true" : "false";
else if (auto ss = std::get_if<std::vector<std::string>>(&value)) else if (auto ss = std::get_if<std::vector<std::string>>(&value))
valueS = concatStringsSep(" ", *ss); // FIXME: evil valueS = concatStringsSep(" ", *ss); // FIXME: evil

View file

@ -254,7 +254,7 @@ static Flake getFlake(
else if (setting.value->type() == nInt) else if (setting.value->type() == nInt)
flake.config.settings.insert({setting.name, state.forceInt(*setting.value, *setting.pos)}); flake.config.settings.insert({setting.name, state.forceInt(*setting.value, *setting.pos)});
else if (setting.value->type() == nBool) else if (setting.value->type() == nBool)
flake.config.settings.insert({setting.name, state.forceBool(*setting.value, *setting.pos)}); flake.config.settings.insert({setting.name, Explicit<bool> { state.forceBool(*setting.value, *setting.pos) }});
else if (setting.value->type() == nList) { else if (setting.value->type() == nList) {
std::vector<std::string> ss; std::vector<std::string> ss;
for (auto elem : setting.value->listItems()) { for (auto elem : setting.value->listItems()) {

View file

@ -18,6 +18,7 @@ chmod +x echoing-post-hook.sh
cat <<EOF > flake.nix cat <<EOF > flake.nix
{ {
nixConfig.post-build-hook = "$PWD/echoing-post-hook.sh"; nixConfig.post-build-hook = "$PWD/echoing-post-hook.sh";
nixConfig.allow-dirty = false; # See #5621
outputs = a: { outputs = a: {
defaultPackage.$system = import ./simple.nix; defaultPackage.$system = import ./simple.nix;