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
nixos/networkd: fix range assertions on 32 bit Nix #45722
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep checking ranges but choose the upper bound depending on the platform.
assertInt = name: group: attr: | ||
optional (attr ? ${name} && !isInt attr.${name}) | ||
"Systemd ${group} field `${name}' is not an integer"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isInt
allows any integer, even negative, so this significantly weakens the assertion too much.
You should keep checking for a range with assertRange
but replace the hardcoded upper bound 4294967295
with the largest positive integer depending on the platform's bitsize.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just checking if it is larger then 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this particular case there may be a simpler solution: just check for isInt
and the lower bound , so you don't have to specify the upper bound.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(guess we were writing in parallel 😄)
2d8eb84
to
bdcb5fb
Compare
I added checks that the value is >= 0. I also kept the Also, if NixOS/nix#2378 is merged, this PR would no longer be necessary. |
Thanks. Nitpick: When the lower bound was 1 before, you should |
bdcb5fb
to
442681c
Compare
Oops, fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Motivation for this change
Range assertions were recently added to the networkd module that exceeded the range of a signed 32-bit int, breaking the module on 32 bit Nix.
Things done
This PR changes those assertions to checks that the value is an int, as suggested in #44233 (comment).
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)