Skip to content

opencv: fix != "x86_64-darwin" check; also use lib.systems.equals#403629

Open
MattSturgeon wants to merge 5 commits intoNixOS:masterfrom
MattSturgeon:opencv-platform
Open

opencv: fix != "x86_64-darwin" check; also use lib.systems.equals#403629
MattSturgeon wants to merge 5 commits intoNixOS:masterfrom
MattSturgeon:opencv-platform

Conversation

@MattSturgeon
Copy link
Contributor

  • opencv: replace == with lib.systems.equals
  • ovencv: fix platform != "x86_64-darwin" check
  • opencv: show unsupported platform in ICV error

Found this while working on #380005, the existing effectiveStdenv.buildPlatform != "x86_64-darwin" condition will never be false, because buildPlatform is never a string.

I've replaced this with !(isx86_64 && isDarwin), however I suspect it may not need to be quite this specific?

Additionally I've replaced the usage of == to compare platforms with the more correct lib.systems.equals. However, it may be more accurate to use buildPlatform.canExecute hostPlatform.

I've included some FIXME comments in the diff; if maintainers/reviewers can clarify intent, I'd like to resolve them in this PR. Otherwise they can be addressed in future work.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label May 2, 2025
@MattSturgeon MattSturgeon changed the title opencv: fix != "x86_64-darwin" check; also use lib.systems.equals opencv: fix != "x86_64-darwin" check; also use lib.systems.equals May 2, 2025
@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels May 2, 2025
Comment on lines +459 to +460
# FIXME: Do we actually want `equals`, or should we use `canExec`?
++ optionals (sysEquals effectiveStdenv.hostPlatform effectiveStdenv.buildPlatform) [
Copy link
Member

Choose a reason for hiding this comment

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

That probably should be canExec

pythonPackages.python
]
++ optionals (effectiveStdenv.buildPlatform == effectiveStdenv.hostPlatform) [
# FIXME: Do we actually want `equals`, or should we use `canExec`?
Copy link
Member

Choose a reason for hiding this comment

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

This probably means "when not doing cross"

}
// optionalAttrs (!enablePython) { pythonEnabled = pythonPackages.opencv4; }
// optionalAttrs (effectiveStdenv.buildPlatform != "x86_64-darwin") {
# FIXME: is !(isx86_64 && isDarwin) correct, or should it be more general, like !isDarwin ?
Copy link
Member

Choose a reason for hiding this comment

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

Maybe #208351 can answer that?

There's no reason to have a checkPhase input in `nativeBuildInputs` when
`nativeCheckInputs` exists.
@github-actions github-actions bot added 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux. and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels May 2, 2025
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jul 28, 2025
@nixpkgs-ci nixpkgs-ci bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: darwin Running or building packages on Darwin 10.rebuild-darwin: 101-500 This PR causes between 101 and 500 packages to rebuild on Darwin. 10.rebuild-linux: 101-500 This PR causes between 101 and 500 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants