buildRustPackage: only set RUSTFLAGS if non-empty#464992
buildRustPackage: only set RUSTFLAGS if non-empty#464992HeitorAugustoLN wants to merge 1 commit intoNixOS:stagingfrom
Conversation
Previously, the refactor of `buildRustPackage` caused `RUSTFLAGS` to be defined in the environment unconditionally, often resulting in an empty string (`RUSTFLAGS=""`). When `RUSTFLAGS` is set (even to an empty string), Cargo prioritizes it and ignores `CARGO_TARGET_<TRIPLE>_RUSTFLAGS`. This behavior broke packages like `cosmic-comp` that rely on target-specific flags for linking libraries (e.g., `libEGL`). This change calculates the flags beforehand and uses `lib.optionalAttrs` to ensure `RUSTFLAGS` is only added to the environment if it contains a value. This restores the ability for Cargo to fall back to target-specific configuration variables.
8ea1897 to
800aea7
Compare
|
Good, but this doesn't change the fact that platform-specific RUSTFLAGS will lose effect once RUSTFLAGS is set 🫠 Only bringing us back to previous status |
Right, but I am pretty sure that this is standard |
|
I think the relevant issue is upstream: rust-lang/cargo#13981 |
|
Should we start using our own flags |
Good idea, try if it works for cosmic? |
Caused by NixOS/nixpkgs#435278 RUSTFLAGS is now always set and overrides whatever we specify in .cargo/config.toml TODO: Keep an eye on NixOS/nixpkgs#464707 NixOS/nixpkgs#464992 and possibly revert or adjust to the new status quo in nixpkgs.
|
This is the same as #464707 |
I don't see these variables exist? |
|
Closing in favor of #464707 |
Closes #464392
Previously, the refactor of
buildRustPackagecausedRUSTFLAGSto be defined in the environment unconditionally, often resulting in an empty string (RUSTFLAGS="").When
RUSTFLAGSis set (even to an empty string), Cargo prioritizes it and ignoresCARGO_TARGET_<TRIPLE>_RUSTFLAGS. This behavior broke packages likecosmic-compthat rely on target-specific flags for linking libraries (e.g.,libEGL).This change calculates the flags beforehand and uses
lib.optionalAttrsto ensureRUSTFLAGSis only added to the environment if it contains a value. This restores the ability for Cargo to fall back to target-specific configuration variables.tested with:
And its getting linked:
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.Add a 👍 reaction to pull requests you find important.