From 5bb7a961480b15440f9d590214c799b19da9aaba Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sat, 20 Sep 2025 17:29:06 +0200 Subject: Reworking structure. Adding proper C exports. Fix needed 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. --- c++/.nix/derivation.nix | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 c++/.nix/derivation.nix (limited to 'c++/.nix/derivation.nix') 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/ + ''; +} -- cgit v1.2.3