The emission of NIX_CONFIG into post-build-hooks breaks post-build-hooks if they use config values incompatible with CppNix #739

Closed
opened 2025-03-14 23:23:21 +00:00 by jade · 2 comments
Owner

Yeah I am not fixing this (and I don't even think it should be fixed because what on earth are you supposed to do about it, we probably need to nuke this entire infrastructure, and I don't think we should stop causing bugs like it either), but I am documenting it.

This was, of course, found at work. What happens is that the post-build-hook receives NIX_CONFIG as an environment variable:

https://git.lix.systems/lix-project/lix/src/f21fd6b7e653230c01b454f486cc51d5cc999667/lix/libstore/build/derivation-goal.cc#L977-L980

This is then a config parse failure on CppNix since they did not adopt consensual accept-flake-config yet, and so their accept-flake-config remains a boolean rather than our tristate (which naturally defaults to a non-boolean value. whelp).

Mercury issue: DUX-3152

*** found package.yaml. Using hpack...
post-build-hook: error: Boolean setting 'accept-flake-config' has invalid value 'ask'
post-build-hook: Try 'nix --help' for more information.
error:
       … while evaluating 'strict' to select 'drvPath' on it
         at /builtin/derivation.nix:1:552:
       … while calling the 'derivationStrict' builtin
         at /builtin/derivation.nix:1:208:
       (stack trace truncated; use '--show-trace' to show the full trace)

       error: program '/nix/store/aaaaaaaaaaaaaaaaaaaaaaa-cache-hook/bin/cache-hook' failed with exit code 123
Yeah I am not fixing this (and I don't even think it should be fixed because what on earth are you supposed to do about it, we probably need to nuke this entire infrastructure, and I don't think we should stop causing bugs like it either), but I am documenting it. This was, of course, found at work. What happens is that the post-build-hook receives NIX_CONFIG as an environment variable: https://git.lix.systems/lix-project/lix/src/f21fd6b7e653230c01b454f486cc51d5cc999667/lix/libstore/build/derivation-goal.cc#L977-L980 This is then a config parse failure on CppNix since they did not adopt consensual accept-flake-config yet, and so their accept-flake-config remains a boolean rather than our tristate (which naturally defaults to a non-boolean value. whelp). Mercury issue: DUX-3152 ``` *** found package.yaml. Using hpack... post-build-hook: error: Boolean setting 'accept-flake-config' has invalid value 'ask' post-build-hook: Try 'nix --help' for more information. error: … while evaluating 'strict' to select 'drvPath' on it at /builtin/derivation.nix:1:552: … while calling the 'derivationStrict' builtin at /builtin/derivation.nix:1:208: (stack trace truncated; use '--show-trace' to show the full trace) error: program '/nix/store/aaaaaaaaaaaaaaaaaaaaaaa-cache-hook/bin/cache-hook' failed with exit code 123 ```
Author
Owner

Okay, on one hand this is a ridiculous issue, but on the other hand we can only output overridden settings into the build hook, like we do with the protocol.

Okay, on one hand this is a ridiculous issue, but on the other hand we can only output overridden settings into the build hook, like we do with the protocol.
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/2800 ("post-build-hook: don't emit config settings that aren't overridden")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/2800", "number": 2800, "kind": "commit message"}], "cl_meta": {"2800": {"change_title": "post-build-hook: don't emit config settings that aren't overridden"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/2800](https://gerrit.lix.systems/c/lix/+/2800) ("post-build-hook: don't emit config settings that aren't overridden")
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#739
No description provided.