-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
Conversation
Ohh I did not expect to see this problem in practice, having noticed it only while handling platforms manually and not through the nixpkgs entrypoint, for testing.
# *Platform omitted for brevity
args@{ host, build }:
let inherit (
# actually this part could be turned into a function
if systems.equals args.host args.build
then { inherit (args) host; build = host; }
else { inherit (args) host build; }
) host build;
in
# use host and build as usual That way we can keep using regular equality on these types. I think the real solution is to either But until we decide that, we may as well fix it for 95% of cases by explicitly making the values identical where it matters most. |
The issue happens simply when just importing Perhaps we could fix 100% of the problem by fixing function comparison in Nix? intrepid = inputs.nixpkgs.lib.nixosSystem {
modules = with tree.hosts.intrepid; [
bootloader
filesystems
plymouth
configuration
packages
powerplan
touchpad
greeter
# gamemode
gaming
pia-openvpn
];
pkgs = import inputs.nixpkgs-unstable {
overlays = [
# flake packages
self.overlays.default
# override packages with an unfree license
self.overlays.allowUnfree
# other packages
inputs.slight.overlays.default
inputs.ragenix.overlays.default
];
localSystem = "x86_64-linux";
crossSystem = "x86_64-linux";
config.allowUnfree = true;
};
specialArgs = {
enableUnstableZfs = false;
};
}; I will see the following error:
To resolve this temporarily I attempted to add |
It's fundamentally unfixable because of undecidability. We should make it throw, but that's a big breaking change.
That shouldn't happen. You've specified I've added a safe alternative read-only nixpkgs module as part of this. Maybe that should be loaded by For now you could fix your example by setting the |
pkgs/stdenv/default.nix
Outdated
@@ -34,9 +34,11 @@ let | |||
|
|||
stagesCustom = import ./custom args; | |||
|
|||
removeFunctions = a: lib.filterAttrs (_: v: !builtins.isFunction v) a; |
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 wrote a similar equality function here https://github.com/NixOS/nixpkgs/pull/231940/files#diff-2165823a8d82c5dd1353601bd290df8bd431f9ee2096750d9ef655cf5d251998
It's a bit more selective about the arguments it ignores, but that might make it unnecessarily fragile. I feel like your solution is probably better.
Though still fragile if someone puts a function in a nested attrset.
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.
Added your solution with the test I previously wrote (almost unchanged)
This seems to me missing the binary cache, I am rebuilding too many things. Tried both This is not a problem when I pass |
this appears to fix the following issue for some reason ``` nix-repl> (import ./. { localSystem.system = "x86_64-linux"; crossSystem.system = "x86_64-linux"; }).bash «derivation /nix/store/5lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv» nix-repl> (import ./. { localSystem.system = "x86_64-linux"; crossSystem = "x86_64-linux"; }).bash «derivation /nix/store/1whiq03rsfrmch2ds3jhyqjaczfz97lb-bash-5.2-p15-x86_64-unknown-linux-gnu.drv» ``` fixed ``` nix-repl> (import ./. { localSystem.system = "x86_64-linux"; crossSystem = "x86_64-linux"; }).bash «derivation /nix/store/5lz9p8xhf89kb1c1kk6jxrzskaiygnlh-bash-5.2-p15.drv» ```
84a684c
to
e5e5fd1
Compare
I have cherry-picked the commits from both pull requests, and add a module
This is happening a lot now and it is very annoying. Sometimes I want to see an error message multiple times. How do I prevent this "cache" error from happening? What does it mean? Why am I seeing it more? Maybe you know about this well enough to save me the trouble of recovering the full trace (this time).
|
Is it possible that the following lines in This is the top of the attrset bound to { # We put legacy `system` into `localSystem`, if `localSystem` was not passed.
# If neither is passed, assume we are building packages on the current
# (build, in GNU Autotools parlance) platform.
localSystem ? { system = args.system or builtins.currentSystem; }
# These are needed only because nix's `--arg` command-line logic doesn't work
# with unnamed parameters allowed by ...
, system ? localSystem.system
, crossSystem ? localSystem Perhaps the issue that you "did not expect to see ... in practice" is caused by this confusing evaluation flow. My tests show otherwise, but I feel as if I am still missing something. nix-repl> test = args @ { localSystem ? { system = args.system; }, system ? localSystem.system, crossSystem ? localSystem }: { inherit localSystem crossSystem; }
nix-repl> :p test { system = "x86_64-linux"; }
{ crossSystem = { system = "x86_64-linux"; }; localSystem = «repeated»; }
nix-repl> :p test { localSystem = "x86_64-linux"; }
{ crossSystem = "x86_64-linux"; localSystem = "x86_64-linux"; }
nix-repl> :p test { localSystem.system = "x86_64-linux"; }
{ crossSystem = { system = "x86_64-linux"; }; localSystem = «repeated»; }
# is this the problem?
nix-repl> :p test { localSystem = "x86_64-linux"; crossSystem = "x86_64-linux"; }
{ crossSystem = "x86_64-linux"; localSystem = "x86_64-linux"; }
nix-repl> :p test { localSystem.system = "x86_64-linux"; crossSystem.system = "x86_64-linux"; }
{ crossSystem = { system = "x86_64-linux"; }; localSystem = { system = "x86_64-linux"; }; } I understand that you both have already looked into this and are aware of this. I guess what I'm still stuck on is this: If they are the same value here, whether string or attrset, default or provided; why does the comparison differ? The following two attrsets can begotten from either the default
So why does the comparison see them as different? Because of the lack of the usage of I'm still trying to wrap my head around this. As far as I can tell, through days of playing with it, the file in which the comparison is performed (before |
Which nix version, and which command is that? |
This is a workaround that lets us use `==` on systems despite the functions that would make `==` always return `false` if a workaround like this is not applied. The real solution is to either use `lib.systems.equals` for all such comparisons, or to remove all functions from the elaborated systems.
Both Nix version is |
if crossSystem0 == null || crossSystem0 == args.localSystem | ||
then localSystem | ||
else lib.systems.elaborate crossSystem0; | ||
if crossSystem0 == null || lib.systems.equals crossSystem0 args.localSystem |
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.
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
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.
crossSystem0 and args.localSystem haven't been elaborated so they're possibly just strings
IMHO we should elaborate unconditionally here.
I think these are the only two reasonable solutions. Does anybody object strongly to (b)? Edit: #238331 |
#254763 which seems to make this unnecessary, was merged. |
this appears to fix the following issue for some reason
fixed
issue reported by @spikespaz on matrix in the cross compilation channel
Description of changes
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)