New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid regular expression breaks kresd NixOS module #156861
Comments
[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
- system: `"x86_64-linux"`
- host os: `Linux 5.10.91, NixOS, 21.11 (Porcupine)`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.3.16`
- channels(root): `"nixos-21.11.335288.3ddd960a3b5"`
- channels(martin): `""`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
[user@system:~]$ nix repl
Welcome to Nix version 2.3.16. Type :? for help.
nix-repl> builtins.match "([0-9.]+):([0-9]+)()" "127.0.0.1:53"
[ "127.0.0.1" "53" "" ] Edit: There are differences in builtins.match between Darwin and Linux. |
NixOS/nix#1537 might be related. |
Empty parantheses are not supported in regular expressions on Darwin/macOS. The old regular expression produces an error during evaluation. This commit fixes that. Nix‘s `builtins.match` works with extend POSIX regular expressions. The specification for these regular expression states[^1] that the result for a left paranthesis immediately followed by a right paranthesis outside of a bracket expression is undefined. [^1]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04_03
I submitted a pull request that should fix this. See #156867. |
This is the obnoxious thing that Nix takes the regexp engine from the C++ library, but the standard does not define such details, so different |
Just my curiosity: you don't use the code to run kresd on a darwin, right? (just to evaluate a NixOS system) |
The Nix expressions are evaluated on my Macbook (aarch64-darwin), and then the derivations are built on a NixOS host (x86_64-linux). See https://nixos.org/manual/nix/stable/advanced-topics/distributed-builds.html and https://nixos.wiki/wiki/Distributed_build for details. Edit: Yes, I evaluate the kresd module for a NixOS system. |
Empty parantheses are not supported in regular expressions on Darwin/macOS. The old regular expression produces an error during evaluation. This commit fixes that. Nix‘s `builtins.match` works with extend POSIX regular expressions. The specification for these regular expression states[^1] that the result for a left paranthesis immediately followed by a right paranthesis outside of a bracket expression is undefined. [^1]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04_03 (cherry picked from commit 6a96992)
Describe the bug
There is an error in the kresd NixOS module. The changed regular expression introduced in #153610 is invalid.
Steps To Reproduce
Steps to reproduce the behavior:
services.kresd.enable = true;
Expected behavior
I guess, the regular expression should not be invalid and thereby should not cause an error during evaluation.
Additional context
This can also be reproduced in
nix repl
:Notify maintainers
@vcunat
The text was updated successfully, but these errors were encountered: