-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
lib/systems: elaborate properly with non-matching system / config / parsed args #351608
lib/systems: elaborate properly with non-matching system / config / parsed args #351608
Conversation
Note to myself: I should probably add a test in |
4a3bf53
to
3db978e
Compare
…arsed args When elaborating a system with both "config" and "system" arguments given, they might not match the parsed results. Example: elaborate { config = "i686-unknown-linux-gnu"; system = "x86_64-linux"; } This would result in a parsed system for i686, because the config argument is preferred. But since "// args //" comes after system has been inferred from parsed, it is overwritten again. This results in config and parsed all pointing to i686, while system still tells the story of x86_64. Inconsistent arguments can also be given when passing "parsed" directly. This happened in stage.nix for the various package sets. The solution is simple: One of the three arguments needs to be treated as the ultimate source of truth. "system" can already be losslessly extracted from "parsed". However, "config" currently can not, for example for various -mingw32 cases. Thus everything must be derived from "config". To do so, "system" and "parsed" arguments are made non-overrideable for systems.elaborate. This means, that "system" will be used to parse when "config" is not given - and "parsed" will be ignored entirely. The systemToAttrs helper is exposed on lib.systems, because it's useful to deal with top-level localSystem / crossSystem arguments elsewhere.
3db978e
to
3c21a5c
Compare
Added some tests to show the bad and fixed behavior. Before these changes, the tests fail like this:
The result is self-conflicting elaborated systems, which leads to problems downstream. After, the tests pass. |
@infinisil Looking at the ci/OWNERS file, I don't understand why the bot pinged you. Or why it did now, but not before. On the latest force push, I only added tests to |
Would appreciate a review. @NixOS/stdenv anyone? |
Indeed, that's the case:
Not a problem though 🙂 |
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.
I like it. Intend to merge sometime today unless there are objections.
system = parse.doubleFromSystem final.parsed; | ||
# TODO: This currently can't be losslessly-extracted from `parsed`, for example |
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.
Rather than TODO
, is there an issue we can cite?
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.
This came from this discussion: #303849 (comment)
Not sure which of Adam Joseph's PRs was meant there, but could be #249090?
If you got here after the latest bump introduced you to this error:
You probably have a |
This is broken out of #303849, because even if that PR has stalled for now, imho it's still useful to fix
lib.systems.elaborate
.When elaborating a system with both
config
andsystem
arguments given, they might not match theparsed
results. Example:This would result in a parsed system for i686, because the
config
argument is preferred. But since// args //
comes after system has been inferred from parsed, it is overwritten again. This results inconfig
andparsed
all pointing to i686, whilesystem
still tells the story of x86_64.Inconsistent arguments can also be given when passing
parsed
directly. This happened in stage.nix for the various package sets.The solution is simple: One of the three arguments needs to be treated as the ultimate source of truth.
system
can already be losslessly extracted fromparsed
. However,config
currently can not, for example for various -mingw32 cases. Thus everything must be derived fromconfig
.To do so,
system
andparsed
arguments are made non-overrideable forlib.systems.elaborate
. This means, thatsystem
will be used to parse whenconfig
is not given - andparsed
will be ignored entirely (why elaborate an already elaborated system anyway?).The
systemToAttrs
helper is exposed onlib.systems
, because it's useful to deal with top-levellocalSystem
/crossSystem
arguments elsewhere (not in this PR).@NixOS/stdenv
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.