diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-09-20 17:29:06 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-09-20 17:29:06 +0200 |
commit | 5bb7a961480b15440f9d590214c799b19da9aaba (patch) | |
tree | 6da25c0f30e7b7c2ad3905d6d553fc4db7193590 /c++/.nix/derivation.nix | |
parent | 043268f76a60e4ece9d5485fdb806ad174afc9ad (diff) |
Reworking structure. Adding proper C exports. Fix neededmain
emcc is annoying me with its caching. Tries to write into /nix/store
locations, which is shouldn't do. Need the proper env variable to
rewrite. Otherwise it'll be ignored.
Diffstat (limited to 'c++/.nix/derivation.nix')
-rw-r--r-- | c++/.nix/derivation.nix | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/c++/.nix/derivation.nix b/c++/.nix/derivation.nix new file mode 100644 index 0000000..a47b023 --- /dev/null +++ b/c++/.nix/derivation.nix @@ -0,0 +1,31 @@ +{ lib +, stdenv +, pname +, version +}: + +stdenv.mkDerivation { + inherit pname version; + + src = ./..; + + dontConfigure = true; + buildPhase = '' + HOME=$(pwd) + EM_CACHE=$TMPDIR/emscripten_cache + emcc lights_out.cpp \ + -s WASM=1 \ + -s EXPORTED_FUNCTIONS='["_fake_main"]' \ + -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' \ + -o lights_out.js + ''; + + # Silence the warnings for now + checkPhase = '' + ''; + + installPhase = '' + mkdir -p $out + cp lights_out.{wasm,js} $out/ + ''; +} |