Skip to content
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

stdenv: fix crossSystem localSystem comparison #237427

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions pkgs/top-level/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,24 @@ in let

localSystem = lib.systems.elaborate args.localSystem;

# Condition preserves sharing which in turn affects equality.
# Condition preserves sharing which in turn improves equality within this Nixpkgs.
#
# Use `lib.systems.equals` to compare systems.
crossSystem =
if crossSystem0 == null || crossSystem0 == args.localSystem
then localSystem
else lib.systems.elaborate crossSystem0;
if crossSystem0 == null || lib.systems.equals crossSystem0 args.localSystem
Copy link
Member Author

@Artturin Artturin Jun 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://gist.github.com/GrahamcOfBorg/1e800ef80702f76206b24b79c9f0dc1d

error: value is a string while a set was expected

crossSystem0 and args.localSystem haven't been elaborated so they're possibly just strings

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crossSystem0 and args.localSystem haven't been elaborated so they're possibly just strings

IMHO we should elaborate unconditionally here.

then
# This makes `crossSystem == localSystem` so that comparisons with `==`
# work **in the context of this single Nixpkgs invocation**.
#
# Equality is still broken when comparing between two Nixpkgs instances:
#
# (import <nixpkgs> {}).stdenv.hostPlatform
# != (import <nixpkgs> {}).stdenv.hostPlatform
localSystem
else
# It's a truly different system, so no significant equality problems.
# We only have to elaborate it, just like we did for localSystem above.
lib.systems.elaborate crossSystem0;

# Allow both:
# { /* the config */ } and
Expand Down