Skip to content

sdl2-compat: add setup hook and minor fixes#388079

Merged
K900 merged 3 commits intoNixOS:masterfrom
marcin-serwin:push-yqknyylorstk
Mar 14, 2025
Merged

sdl2-compat: add setup hook and minor fixes#388079
K900 merged 3 commits intoNixOS:masterfrom
marcin-serwin:push-yqknyylorstk

Conversation

@marcin-serwin
Copy link
Contributor

@marcin-serwin marcin-serwin commented Mar 7, 2025

This adds a setup hook analogous to the one used by SDL2 package that
picks up satelitte libraries during build time. This makes it possible
to replace SDL2 with sdl2-compat in packages using satelitte libraries
without further changes to build flags.

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.

@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 Mar 7, 2025
@nix-owners nix-owners bot requested a review from nadiaholmquist March 7, 2025 23:38
@nadiaholmquist
Copy link
Contributor

Seems good to me. I wasn't exactly sure ehat the purpose of the setup hook for SDL2 was, and it seemed to work fine without, but we definitely need this if it helps with using sdl2-compat as a replacement for SDL2.

@marcin-serwin
Copy link
Contributor Author

marcin-serwin commented Mar 8, 2025 via email

Copy link
Member

Choose a reason for hiding this comment

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

cmake+ninja is usually way faster than just cmake+make.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm a bit surprised, I always thought that ninja is only faster for incremental builds as claimed, e.g., here. (The article is a bit old though.)

I've benchmarked it for this specific package and ninja is faster by about 2 seconds on my machine:

$ time (runPhase configurePhase && runPhase buildPhase) # cmake+ninja
real    0m7,871s
user    0m39,559s
sys     0m7,954s
$ time (runPhase configurePhase && runPhase buildPhase) # cmake+make
real    0m9,968s
user    0m37,053s
sys     0m10,434s

I'm not sure if this speedup is worth the extra dependency though, especially since CPU time is about the same. (I'm guessing that CPU time is more important for Hydra, is that true?)

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

For some big applications it really makes a difference but regardless I would just leave it here as we plan to use ninja for everything cmake related anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted

Copy link
Contributor

Choose a reason for hiding this comment

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

did you test this, especially on darwin?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't use nix on darwin so I don't have any way to test this currently. I've tested the change on linux.

Note that this line doesn't add darwin to platforms - darwin is unix so it was already there - effectively it only adds windows which I wanted to test but I was blocked by #388297, I will try again shortly now that it's fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, good point. If it was previously unix it should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I managed to cross compile the package itself for windows after fixing the rpath setting, but cross compiling anything dependent on it is problematic, since I realized that the setup hook assumes that host == target. I've tried building a simple game by supplying necessary flags manually but it failed to run in wine with Failed to initialize registry display settings for L"\\\\.\\DISPLAY1". I'm still leaving the platforms set to all since there is nothing unixy required by the library, and the issues are likely caused by cross compiling.

@github-actions github-actions bot removed the 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. label Mar 12, 2025
@wegank wegank added 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels Mar 12, 2025
This adds a setup hook analogous to the one used by SDL2 package that
picks up satelitte libraries during build time. This makes it possible
to replace SDL2 with sdl2-compat in packages using satelitte libraries
without further changes to build flags.
The SDL library has backends for many platforms, not just unix ones,
however, it's currently restricted by its dependencies.
The slow tests rely on timers executing within a specified time which is not necessarily true if system is under a heavy load [1]. These tests are also disabled in the official CI pipeline [2].

[1]: NixOS#386759 (comment)
[2]: https://github.com/libsdl-org/sdl2-compat/blob/9544651fb39deefb2dd1aed9113af3b60898a1bb/.github/workflows/main.yml#L116
@K900 K900 merged commit b52f6f7 into NixOS:master Mar 14, 2025
27 checks passed
@marcin-serwin marcin-serwin deleted the push-yqknyylorstk branch March 15, 2025 08:48
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. 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants