Skip to content

sdl3-image: add option to disable stb and modernize - #400078

Merged
pbsds merged 4 commits into
NixOS:masterfrom
evysgarden:sdl3-image-disable-stbi
Apr 23, 2025
Merged

pbsds merged 4 commits into
NixOS:masterfrom
evysgarden:sdl3-image-disable-stbi

Conversation

@evysgarden

@evysgarden evysgarden commented Apr 19, 2025 •

Copy link
Copy Markdown
Contributor

Resolves #400074

Things done

Disabled stbi and added libpng and libjpeg to build deps.

  • 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.

@evysgarden evysgarden self-assigned this Apr 19, 2025
@github-actions github-actions Bot added 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Apr 19, 2025
@marcin-serwin

marcin-serwin commented Apr 20, 2025 •

Copy link
Copy Markdown
Contributor

I think we should avoid changing upstream configuration when it's not required since this may cause issues if some dependent package relies on STB backend being used. IMO we should add a parameter like enableSTB that defaults to true controlling this and if someone wants to avoid using STB they can override it.

@GrimmTheShrimp

Copy link
Copy Markdown
Contributor

I disagree with the "more security" take here: libpng and libjpeg are notorious for having security issues themselves. sdl3 and its "plugins" are surprisingly well-maintained upstream, and i'd guess any potential discovered vuln will be fixed quite quickly. I'd approve an option to do just that, but i'd agree with marcin it should not be the default.

@evysgarden

Copy link
Copy Markdown
Contributor Author

yeah that makes sense. i will change that

@evysgarden
evysgarden force-pushed the sdl3-image-disable-stbi branch from 8a9251a to d5afef5 Compare April 20, 2025 14:32
@evysgarden evysgarden changed the title sld3-image: disable stbi sld3-image: add option to disable stb Apr 20, 2025

@GrimmTheShrimp GrimmTheShrimp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for adding the option :)

Comment thread pkgs/by-name/sd/sdl3-image/package.nix Resolved
@evysgarden evysgarden changed the title sld3-image: add option to disable stb sld3-image: add option to disable stb and remove apple_sdk Apr 20, 2025
@evysgarden

Copy link
Copy Markdown
Contributor Author

I'm considering adding a passthru update script since it uses github. but I'm gonna read into that tmrw and would prbly add that in a separate pull request.

@GrimmTheShrimp GrimmTheShrimp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks

For update script, if you want to:

passthru.updateScript = nix-update-script { };

@marcin-serwin

Copy link
Copy Markdown
Contributor

You'll need to use a version regex to avoid picking up 2.x releases:

passthru.updateScript = nix-update-script {
  extraArgs = [
    "--version-regex"
    "release-(3\\..*)"
  ];
};

@evysgarden

Copy link
Copy Markdown
Contributor Author

thx @marcin-serwin. am pretty busy rn. so this is gonna wait till tmrw or later this evening.
I'll change this to draft and add the follwing changes:

  • add updatescript
  • remove usage of with (in maintainers)

@evysgarden
evysgarden marked this pull request as draft April 20, 2025 17:49
@evysgarden evysgarden changed the title sld3-image: add option to disable stb and remove apple_sdk sld3-image: add option to disable stb and modernize Apr 20, 2025
@GrimmTheShrimp

Copy link
Copy Markdown
Contributor

i believe with lib.maintainers; is fine, just meta = with lib; is frowned upon.

@evysgarden

Copy link
Copy Markdown
Contributor Author

ic. it's a bit difficult to get a grasp of what is considered good practice around nixpkgs.
I will remove the with nonetheless since I'm currently the sole maintainer. If that changes in the future, I'll add it back.

@GrimmTheShrimp

Copy link
Copy Markdown
Contributor

ic. it's a bit difficult to get a grasp of what is considered good practice around nixpkgs. I will remove the with nonetheless since I'm currently the sole maintainer. If that changes in the future, I'll add it back.

I absolutely agree, and the relevant issue about that is #387072

Until that settles, the best we can do is try to imitate what everyone else does. Sorry, this is indeed confusing, you are doing well!

@evysgarden
evysgarden marked this pull request as ready for review April 20, 2025 22:57
@evysgarden

Copy link
Copy Markdown
Contributor Author

think I'm content now with the package.
it's 00:57 here in Germany. good night

@GrimmTheShrimp
GrimmTheShrimp requested a review from pbsds April 21, 2025 06:55
@wegank wegank added the 12.approvals: 2 This PR was reviewed and approved by two persons. label Apr 21, 2025
@pbsds

pbsds commented Apr 21, 2025

Copy link
Copy Markdown
Member

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 400078


x86_64-linux

✅ 3 packages built:
  • sdl3-image
  • sdl3-image.dev
  • sdl3-image.lib

aarch64-linux

✅ 3 packages built:
  • sdl3-image
  • sdl3-image.dev
  • sdl3-image.lib

x86_64-darwin

❌ 3 packages failed to build:
  • sdl3-image
  • sdl3-image.dev
  • sdl3-image.lib

aarch64-darwin

❌ 3 packages failed to build:
  • sdl3-image
  • sdl3-image.dev
  • sdl3-image.lib

@pbsds

pbsds commented Apr 21, 2025

Copy link
Copy Markdown
Member

darwin error:

2025-04-21 18:14:50.221 testimage[47422:20741284] ERROR: 04/21/25 18:14:50: Comparison of pixels with allowable error of 300 failed 966 times.
2025-04-21 18:14:50.221 testimage[47422:20741284] ERROR: 04/21/25 18:14:50: Reference surface format: SDL_PIXELFORMAT_ABGR8888
2025-04-21 18:14:50.221 testimage[47422:20741284] ERROR: 04/21/25 18:14:50: Actual surface format: SDL_PIXELFORMAT_ABGR8888
2025-04-21 18:14:50.221 testimage[47422:20741284] ERROR: 04/21/25 18:14:50: First detected occurrence at position 0,0 with a squared RGB-difference of 63509.
2025-04-21 18:14:50.221 testimage[47422:20741284] ERROR: 04/21/25 18:14:50: Reference pixel: R=252 G=2 B=1 A=255
2025-04-21 18:14:50.221 testimage[47422:20741284] ERROR: 04/21/25 18:14:50: Actual pixel   : R=0 G=0 B=0 A=255
2025-04-21 18:14:50.221 testimage[47422:20741284] ERROR: 04/21/25 18:14:50: Surfaces from failed comparison saved as 'CompareSurfaces0001_TestOutput.bmp' and 'CompareSurfaces0001_Reference.bmp'
2025-04-21 18:14:50.221 testimage[47422:20741284] ERROR: 04/21/25 18:14:50: Assert 'Surface differed from reference by at most 300 in 966 pixels': Failed

it builds fine on master (https://hydra.nixos.org/build/294924456), meaning there is a breakage here

@GrimmTheShrimp

Copy link
Copy Markdown
Contributor

That is surprising, no change made ehre should affect darwin specifically? Foundation was dropped, but i understand that is part of the stdenv on darwin and doesn't need to be explicitly specified?

@GrimmTheShrimp

GrimmTheShrimp commented Apr 21, 2025 •

Copy link
Copy Markdown
Contributor

@GrimmTheShrimp

Copy link
Copy Markdown
Contributor

what happens if you build with enableSTB = false on darwin?

@marcin-serwin

Copy link
Copy Markdown
Contributor

This failure occurs when testing avif file which uses libavif regardless of platform and this PR does not touch that. This patch is branched off of 2 weeks old master and there were some updates for this lib in the meantime, could you check if the failure still occurs after rebase?

@evysgarden
evysgarden force-pushed the sdl3-image-disable-stbi branch from b2d47e4 to c705d86 Compare April 21, 2025 23:06
@evysgarden

Copy link
Copy Markdown
Contributor Author

i rebased to master to see if that fixes the issue

@evysgarden evysgarden changed the title sld3-image: add option to disable stb and modernize sdl3-image: add option to disable stb and modernize Apr 21, 2025
@marcin-serwin

marcin-serwin commented Apr 22, 2025 •

Copy link
Copy Markdown
Contributor

I've been playing around with nixpkgs-review-gha macOS runner (aarch64-darwin) and I've noticed the following

  • I can't rebuild the sdl3-image package from master, I get the same error as @pbsds
  • Rebuilding libavif succeeds but shows error that output differs from the one in hydra cache

Based on these I suspect that there is some impurity in libavif package that allows the hydra build of sdl3-image to pass but fails in the github runners. The reported darwin failures are most likely not caused by this PR.

@evysgarden

Copy link
Copy Markdown
Contributor Author

thanks for looking into that. could you open an issue for that? since you already tested around.

as for this pr, I'd appreciate it being merged nonetheless, since the issue is not caused by the pr.

especially because I'd like to backport sdl3-image with the changes in this pr into stable.

@evysgarden

Copy link
Copy Markdown
Contributor Author

i have a macbook and will try to repreduce the issue on x86_64-darwin

@GrimmTheShrimp

Copy link
Copy Markdown
Contributor

Trying to build sdl3-image on master aarch64-darwin (thank you friend who gave me access) has some spooky fails:

error: derivation '/nix/store/crs28np80c1bz33q3siz7npj12lvrm7m-sdl3-image-3.2.4.drv' may not be deterministic: output '/nix/store/4qa91nji0f79r0r1m7cign3yisd545ci-sdl3-image-3.2.4-lib' differs

Similarly, building libavif:

error: derivation '/nix/store/vyi7w750x9am8j5gpa8375ip1nb0iyl2-libavif-1.2.1.drv' may not be deterministic: output '/nix/store/pwr20l7ffbc9njbyivlpsx5hh4w7jlzl-libavif-1.2.1' differs

I'll second the request to just merge this and figure out the darwin brokenness some other way. @GaetanLepage pinging you, you seem to have a lot of fun with broken darwin builds and you were also touching sdl-adjacent things recently.

@marcin-serwin marcin-serwin mentioned this pull request Apr 22, 2025
2 tasks done
@isabelroses isabelroses removed the 12.approvals: 2 This PR was reviewed and approved by two persons. label Apr 23, 2025
@pbsds

pbsds commented Apr 23, 2025

Copy link
Copy Markdown
Member

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 400078


x86_64-linux

✅ 3 packages built:
  • sdl3-image
  • sdl3-image.dev
  • sdl3-image.lib

aarch64-linux

✅ 3 packages built:
  • sdl3-image
  • sdl3-image.dev
  • sdl3-image.lib

x86_64-darwin

❌ 3 packages failed to build:
  • sdl3-image
  • sdl3-image.dev
  • sdl3-image.lib

aarch64-darwin

❌ 3 packages failed to build:
  • sdl3-image
  • sdl3-image.dev
  • sdl3-image.lib

@pbsds

pbsds commented Apr 23, 2025 •

Copy link
Copy Markdown
Member

#400078 (comment) to me indicates that the imageio backend depends on some impure library from the macOS install, which explains why the pinning tests break on some hosts but not all. If the build passes on hydra then this sounds like a problem for upstream.

@pbsds

pbsds commented Apr 23, 2025

Copy link
Copy Markdown
Member

... and it passed on x86_64-darwin ofborg

@pbsds
pbsds merged commit 356953c into NixOS:master Apr 23, 2025
@evysgarden

Copy link
Copy Markdown
Contributor Author

yey ^^

thx a lot for everyone who helped me here. @marcin-serwin @LordGrimmauld @pbsds
<3

@evysgarden
evysgarden deleted the sdl3-image-disable-stbi branch April 23, 2025 16:31
@GaetanLepage

Copy link
Copy Markdown
Contributor

@GaetanLepage pinging you, you seem to have a lot of fun with broken darwin builds and you were also touching sdl-adjacent things recently.

I indeed had a lot of fun with that. I'm afraid I can't tell you much more about this...

@GrimmTheShrimp

Copy link
Copy Markdown
Contributor

All good, just figured if anyone had an idea then you. If this is just spooky and accepted as spooky, thats fine by me too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sdl3-image: disable STBI for more security and performance

7 participants