summaryrefslogtreecommitdiff
path: root/modules/webgl/.nix
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2026-11-13 14:12:49 +0100
committerClaudius "keldu" Holeksa <mail@keldu.de>2026-11-13 14:12:49 +0100
commite821d617802ebbfff756844e4d9720342fc78a4e (patch)
tree1dcf33b84698b5074218e44ea491b77a9c23ee66 /modules/webgl/.nix
parent0c0087ef9482634273ec1a23d3a915754f94926d (diff)
downloadlibs-lbm-dev.tar.gz
Swarm POCdev
Diffstat (limited to 'modules/webgl/.nix')
-rw-r--r--modules/webgl/.nix/derivation.nix58
1 files changed, 58 insertions, 0 deletions
diff --git a/modules/webgl/.nix/derivation.nix b/modules/webgl/.nix/derivation.nix
new file mode 100644
index 0000000..3654615
--- /dev/null
+++ b/modules/webgl/.nix/derivation.nix
@@ -0,0 +1,58 @@
+{ lib
+, stdenv
+, scons
+, clang-tools
+, emscripten
+, python3
+, nodejs
+, pname
+, version
+, kel
+}:
+
+stdenv.mkDerivation {
+ pname = "${pname}-webgl";
+ inherit version;
+ src = ./..;
+
+ nativeBuildInputs = [
+ scons
+ clang-tools
+ emscripten
+ python3
+ nodejs
+ ];
+
+ # Deliberately empty. em++ is not a nix cc-wrapper, so it never reads
+ # NIX_CFLAGS_COMPILE and cannot consume buildInputs the way core and sycl do.
+ # Include roots are handed to scons explicitly below, which also has the
+ # virtue of making the dependency visible rather than ambient.
+ buildInputs = [ ];
+
+ sconsFlags = [
+ "kel_include=${kel.lbm.core.dev}/include:${kel.lbm.swarm.dev}/include"
+ ];
+
+ # Same class of problem as the `export HOME="$TMPDIR"` AdaptiveCpp hack in
+ # modules/sycl/.nix/derivation.nix: a toolchain that insists on a writable
+ # cache inside a read-only build.
+ #
+ # emscripten's wrappers source locate_cache.sh, which points EM_CACHE at a
+ # /tmp path. In the sandbox that is writable but empty, so emcc would
+ # rebuild the entire sysroot for every target. Seed it from the cache the
+ # emscripten derivation already precompiled (~81MB, with sysroot and
+ # sysroot_install.stamp) and make it writable.
+ preBuild = ''
+ export HOME="$TMPDIR"
+ export EM_CACHE="$TMPDIR/em_cache"
+ cp -r ${emscripten}/share/emscripten/cache "$EM_CACHE"
+ chmod -R u+w "$EM_CACHE"
+ '';
+
+ # Nothing here can run without a browser; the probe only has to link.
+ doCheck = false;
+
+ preferLocalBuild = true;
+
+ outputs = [ "out" "dev" ];
+}