diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-11-13 14:12:49 +0100 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-11-13 14:12:49 +0100 |
| commit | e821d617802ebbfff756844e4d9720342fc78a4e (patch) | |
| tree | 1dcf33b84698b5074218e44ea491b77a9c23ee66 /poc/web_swarm/worker/.nix/derivation.nix | |
| parent | 0c0087ef9482634273ec1a23d3a915754f94926d (diff) | |
| download | libs-lbm-dev.tar.gz | |
Swarm POCdev
Diffstat (limited to 'poc/web_swarm/worker/.nix/derivation.nix')
| -rw-r--r-- | poc/web_swarm/worker/.nix/derivation.nix | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/poc/web_swarm/worker/.nix/derivation.nix b/poc/web_swarm/worker/.nix/derivation.nix new file mode 100644 index 0000000..694d951 --- /dev/null +++ b/poc/web_swarm/worker/.nix/derivation.nix @@ -0,0 +1,80 @@ +{ lib +, stdenv +, scons +, clang-tools +, emscripten +, python3 +, nodejs +, pname +, version +, kel +}: + +stdenv.mkDerivation { + pname = "${pname}-web-swarm-worker"; + 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 the native + # builds 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:" + + "${kel.lbm.webgl.dev}/include") + ]; + + # Same class of problem as the AdaptiveCpp HOME hack in + # modules/sycl/.nix/derivation.nix: a toolchain that insists on a writable + # cache inside a read-only build. Seed it from the cache the emscripten + # derivation already precompiled, or every build rebuilds the sysroot. + preBuild = '' + export HOME="$TMPDIR" + export EM_CACHE="$TMPDIR/em_cache" + cp -r ${emscripten}/share/emscripten/cache "$EM_CACHE" + chmod -R u+w "$EM_CACHE" + ''; + + # The real worker needs a browser. Its protocol half does not, so that part + # is built for node and run here; only the GL probe is left uncovered. + doCheck = true; + + checkPhase = '' + runHook preCheck + + node ./bin/kel_lbm_worker_selftest.js + + runHook postCheck + ''; + + postInstall = '' + cat > $out/share/kel-lbm/worker/README <<'EOT' + Serve this directory over HTTP and open index.html. + + python3 -m http.server 8000 + + file:// will not work: wasm is fetched and file:// is a null origin. + + The orchestrator is a separate process on its own port -- a WebSocket + server is not an HTTP server, so it does not serve this page. Start it + with kel_lbm_orchestrator and point the page at it, either in the form + on the page or with ?orchestrator=ws://host:port/ + EOT + ''; + + preferLocalBuild = true; + + outputs = [ "out" ]; +} |
