New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
raylib: init at 3.5.0 #98030
raylib: init at 3.5.0 #98030
Conversation
Opened up for review to seek help for the audio issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested example audio_module_playing
. A fatal SIGSEGV
aside, strace
shows attempts to open libpulse
and libasound
, though these aren't declared dependencies of either the raylib ELF library nor the compiled binary. This will need abit more wrapping / ELF wrangling to work.
Additionally the pkgconfig file in lib/pkgconfig/raylib.pc
has broken paths and will need some more attention as well.
prefix=/nix/store/kxlh5s1p5ld9bxk22wrl1zpglx493apw-raylib-3.0.0
exec_prefix=${prefix}
libdir=${exec_prefix}//nix/store/kxlh5s1p5ld9bxk22wrl1zpglx493apw-raylib-3.0.0/lib
includedir=${prefix}//nix/store/kxlh5s1p5ld9bxk22wrl1zpglx493apw-raylib-3.0.0/include
Thanks for the helpful comments. I'll address them tomorrow =) |
I don't fully grok this one. Regarding raylib.pc, |
3a9795a
to
4ca8f3a
Compare
I've pushed the trivial changes you mentioned above.
I'd also like to expose the wayland option (Cmake flag |
Ok, took a further look and the USE_WAYLAND is just fed into the GLFW build, which makes sense. As I'm using the standard Nix package, I'll remove that option. Looks like the x11 libs are required regardless then. OSX support uses CoreAudio and some other options. As I don't have ways to test these other platforms, I'm just going to constrain this to Linux / X11. |
858303c
to
aed811b
Compare
For some reason the lib paths that are being search don't include alsa. I'm not sure why because the other dependencies (glu, etc) are there. If I add
to the definition, then audio plays - at least in the nix-shell used to build the library. But I have a feeling that's not the correct solution here. |
50ae59f
to
bbcedca
Compare
bbcedca
to
d1ed6ae
Compare
First things first, you prolly want to make { stdenv
# …
, alsaSupport ? stdenv.hostPlatform.isLinux
, alsaLib
, pulseSupport ? stdenv.hostPlatform.isLinux
, libpulseaudio
# …
}:
stdenv.mkDerivation rec {
# …
buildInputs = [
# …
]
++ lib.optional alsaSupport alsaLib
++ lib.optional pulseSupport libpulseaudio;
# …
}
A dependency in But that's not the only way a library can be loaded, and it's not always the preferred method. Presumably in the case of raylib (assuming both ALSA and PulseAudio are used at buildtime for their headers), the audio dependencies are just "enabled", not "required". This means that the code could use PulseAudio if it's available at runtime, but if it cannot be found then execution can continue and it may, for example, gracefully fall back to trying ALSA next, or continue without any audio. If these dependencies were handled via declared ELF dependencies, then execution would abort immediately the moment those libraries cannot be located. So such loading mechanisms require additional investigation and wrapping to function correctly. There are multiple ways to resolve this. Generally, polluting
{
preFixup = if (stdenv.hostPlatform.isLinux && (alsaSupport || pulseSupport)) then ''
${lib.optionalString alsaSupport "patchelf --add-needed ${alsaLib}/lib/libasound.so $out/lib/libraylib.so"}
${lib.optionalString pulseSupport "patchelf --add-needed ${libpulseaudio}/lib/libpulse.so $out/lib/libraylib.so"}
'' else ""; # or a section for stdenv.hostPlatform.isDarwin w/ install_name_tool if needed
} This can prolly be made to look prettier ofc and I didn't test this, stuck bisecting another PR's regressions rn sorry. Hope this more detailed explanation helps you understand the gist of the problem! |
No that's a very helpful response and makes sense. |
d1ed6ae
to
189be1b
Compare
Great, that worked. The only remaining issue is the pkconfig/raylib.pc file. |
You should notify upstream that they construct those paths in their pkg-config file improperly. You can link them to jtojnar/cmake-snips for a better explanation, specifically the sections "Assuming If you can't wait until upstream fixes this though, then there are patches in Nixpkgs you could adapt to it in the meantime, see pkgs/development/libraries/yder/fix-pkgconfig.patch. They're also improper but should fix this specific problem for now, just make sure to add a comment linking it to the upstream issue so it can be removed once a proper fix is in place and it's time to update this package. 🙂 |
I really don't know a way to do this. Usually I test less graphical things, just text diffs. |
Just to know: the original tests contained in the upstream project aren't running, but the lib works nonetheless? |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/help-creating-lua-package-in-nix-shell/11754/1 |
Sorry I didn't get notification of your subsequent messages =/ The lib works for me locally. I use it as part of a nix-shell environment and have used both nim and lua bindings with it. There are no actual unit tests. It seems the closest thing to a test is the examples. The examples in 3.5.0 have a bug that prevents them being used to demonstrate the library. If you want to test, you can apply the patch and re-enable compiling the examples by removing "-DBUILD_EXAMPLES=OFF" on line 30. |
About the tests, you can just include the patch explaining that it will be fixed the next version. |
Thanks for the helpful comments! |
@adamlwgriffiths please squash the suggestions into the original commit, maintaining only two (the one adding you to the maintainers and the other creating the expression). |
I know you edited your comment to remove the request to add the patch, but I went a long anyway (why else do anything eh?). I've added the following section
But now I get the following error: wanted: sha256:0lxd8fdld8n3d7ndx5i4302w23chl13h998qgdpbp4xcqag52kdy
got: sha256:1ff5l839wl8dxwrs2bwky7kqa8kk9qmsflg31sk5vbil68dzbzg0
error: build of '/nix/store/d93f74mbshikx2chdx3zffnfhyr5ni9p-source.drv', '/nix/store/n9l2mk70cfl030b08dylb94483y9jxy7-1470.patch.drv' failed It seems thats the resulting hash of the patched source and derivation file, as changing the derivation also changes the hash.
Setting the patch's hash to another value still causes the same issue. I get a different "wanted" hash, but the same "got" hash. |
@adamlwgriffiths, ah, this is a confusing history.
|
That's where I'm confused. Perhaps its how I'm trying to test it. |
Show me all the output, please. Is the |
No, nixpkgs is the version from this PR. |
Try to use this |
omg sorry, its just one of those days. I was editing the same file but in a different directory. Ill update that and do a squash later tonight. |
Oh, it haspens. |
931e41e
to
fd573e0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A final change and everything will be OK.
2da315e
to
5375da0
Compare
Applied and squashed. |
5375da0
to
7023709
Compare
7023709
to
ce3b4a6
Compare
Ok, I think that covers everything then. |
Motivation for this change
Add raylib
3.0.03.5.0Fixes #98029
Execution was tested using the provided examples for both static (rlgl_standalone) and dynamic (other examples).
TODO:
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)