NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.19k stars 14.2k forks source link

SDL for emscripten: emscriptenPackages.SDL2 #141246

Open arximboldi opened 3 years ago

arximboldi commented 3 years ago

Project description

I am building some project with Nix that requires em++ -USE_SDL=2. This causes Emscripten to download SDL, which breaks the sandbox rules of not using the internet.

If I understand correctly, empscriptenPackages is the way to provide these dependencies locally so emscripten does not go online to fetch them and be hermetic. SDL2 seems to be missing there. Or am I missing something?

AndersonTorres commented 3 years ago

How does SDL2 interact with this project?

I have no knowledge on emscripten programming and package management.

arximboldi commented 3 years ago

SDL2 is one of the main libraries supported by Emscripten. It is the go-to way to draw to the screen and make sounds when using Emscripten.

Emscripten is strange, compared to usual C++ compilers, in that when it does not have a library installed locally in it's cache, it just goes ahead and downloads it from the internet and build it. This can be convenient at times, but goes against the Nix model of hermeticity. Instead, in Nixpkgs you have the emscriptenPackages group of derivations that allow you to provide these libraries as buildInputs directly so that emscripten does not try to download them from the internet.

However, SDL2 is missing there.

AndersonTorres commented 3 years ago

REading the documentation, it seems that it should be implemented via overriding. The zlib on emscripten tutorial looks promising.

jb55 commented 3 years ago

yes I ran into this issue a couple months ago. emscripten is also a huge PITA to update in nixpkgs, we should fix that.

arximboldi commented 2 years ago

@veprbl Why was the Issue changed from package request to question? Unless a maintainer of Emscripten for Nix chims in to correct me, I do believe that a package that a package emcriptenPackages.SDL2 not only does make sense, but it would make life of us using both Nix and Emscripten so much easier!