NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.13k stars 14.17k forks source link

Darwin cross `pkgsBuildHost`/`pkgsBuildHost` evaluation regression #355622

Open simonzkl opened 1 day ago

simonzkl commented 1 day ago

Describe the bug

The pkgsBuildHost.<x> and pkgsBuildBuild.<x> derivations evaluate differently when using a cross-compiling nixpkgs instance (darwin -> linux). This is expected for packages like pkg-config where host matters, but not for everything else (e.g. jq). The end result is that almost everything in nativeBuildInputs misses the binary cache and needs to be rebuilt. This could be fixed by moving these packages to depsBuildBuild, but this is a massive change both in nixpkgs and downstream projects.

This is a regression from nixos-24.05. It also works as expected when cross-compiling x86_64-linux -> aarch64-linux, so I think it's something specific to the darwin stdenv in unstable.

Steps To Reproduce

nix-repl> pkgs = import nixpkgs { system = "aarch64-darwin"; }
nix-repl> pkgsCross = import nixpkgs { system = "aarch64-darwin"; crossSystem = "aarch64-linux"; }

nix-repl> pkgs.jq
«derivation /nix/store/gsdqx9n5hclwkadf6hxhlqhd309sb3nn-jq-1.7.1.drv»

nix-repl> pkgsCross.pkgsBuildBuild.jq
«derivation /nix/store/gsdqx9n5hclwkadf6hxhlqhd309sb3nn-jq-1.7.1.drv»

nix-repl> pkgsCross.pkgsBuildHost.jq  
«derivation /nix/store/wxq745g9912lmyakff9mpmjnf3rx6dd3-jq-1.7.1.drv»

Expected behavior

nix-repl> pkgs = import nixpkgs { system = "aarch64-darwin"; }
nix-repl> pkgsCross = import nixpkgs { system = "aarch64-darwin"; crossSystem = "aarch64-linux"; }

nix-repl> pkgs.jq
«derivation /nix/store/gsdqx9n5hclwkadf6hxhlqhd309sb3nn-jq-1.7.1.drv»

nix-repl> pkgsCross.pkgsBuildBuild.jq
«derivation /nix/store/gsdqx9n5hclwkadf6hxhlqhd309sb3nn-jq-1.7.1.drv»

nix-repl> pkgsCross.pkgsBuildHost.jq  
«derivation /nix/store/gsdqx9n5hclwkadf6hxhlqhd309sb3nn-jq-1.7.1.drv»

Additional context

Nixpkgs revision: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2

Notify maintainers

@NixOS/darwin-team

Metadata

 - system: `"aarch64-darwin"`
 - host os: `Darwin 23.6.0, macOS 14.6.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.18.1`
 - nixpkgs: `/nix/store/808lp63z6yiraikjpzcfk3xg1frpd2s0-source`

Add a :+1: reaction to issues you find important.

szlend commented 1 day ago

@NixOS/darwin-core possibly a result of the new stdenv?

reckenrode commented 1 day ago

Probably due to setting NIX_DONT_SET_RPATH_FOR_TARGET when Darwin is the target platform. There’s been talk of reverting it due to the negative impact it’s having.

reckenrode commented 1 day ago

I opened https://github.com/NixOS/nixpkgs/pull/355667 to revert, but it’s technically a breaking change for 24.11, so it presumably needs approval for backporting.