hyperhive/nix/modules
Repository files (latest commit first)
Filename Latest commit message Latest commit date
atlas a9f0955865 nix/hive-matrix: build Imaging.{js,wasm} from source via emscripten (#685, mara feedback)
mara on PR #697: "dont use the prebuilt binary, fix the compile of the
one in nixpkgs (however its easiest: overlay, own derivation based on
it, hell if you want to you can fix buildFlutterApplication, idk)."

Replaces the upstream-tarball vendor with an own derivation that
compiles `Imaging.{js,wasm}` from the `native_imaging` dart package's
C source via `pkgs.emscripten`. Same source provenance as fluffychat
itself uses (both pin native_imaging 0.4.0 from pub.dev), now actually
exercised at build time.

Mechanics: new `fluffychat-web-imaging` derivation in the `let` block:

  - src: `fetchurl` from pub.dev's `native_imaging-0.4.0.tar.gz`
    (hash sha256-ztessYuApDFXjJBo65w+51+N85SR6K2vRxY1usKC1lE=)
  - nativeBuildInputs: emscripten + cmake + gnumake + jq
  - buildPhase: `cd js && make Imaging.js Imaging.wasm`
    (`HOME` + `EM_CACHE` set in TMPDIR so emscripten's sysroot
    builds work in the sandbox — standard nixpkgs pattern for
    emcc-using derivations, see pkgs/top-level/emscripten-packages.nix)
  - installPhase: `install -m 644` the two output files

Closure cost: build-time only — `pkgs.emscripten` is ~3.6 GiB
(LLVM + toolchain). Runtime closure is just the two produced files,
nothing emscripten-shaped survives into the deployed dist.

`postInstall` in `fluffychat-web-fixed` now references
`${fluffychat-web-imaging}` for the install copies, replacing the
previous reference to the deleted `fluffychat-web-imaging-prebuilt`
runCommandLocal.

Verified the emscripten build runs cleanly against the Makefile:

  $ nix-build test-imaging-built.nix
  ...
  emcc -s MODULARIZE=1 -s ALLOW_MEMORY_GROWTH=1 -O3 --closure 1 ...
  cache:INFO: generating system library: sysroot/lib/.../libstubs.a ...
  cache:INFO: generating system library: sysroot/lib/.../libc.a ...
  cache:INFO: generating system library: sysroot/lib/.../libc++-noexcept.a ...
  cache:INFO: generating system library: sysroot/lib/.../libc++abi-noexcept.a ...
  make: Nothing to be done for 'Imaging.wasm'.
  buildPhase completed in 52 seconds
  /nix/store/x5ds7rkrgfgyy3gb1lk44ak8mkdvdx0p-fluffychat-web-imaging-0.4.0
  $ ls /nix/store/.../fluffychat-web-imaging-0.4.0/
  Imaging.js  Imaging.wasm
  $ stat -c '%s' .../Imaging.js .../Imaging.wasm
  9956
  67363

Matches the upstream prebuilt byte-counts (9936 + 67770 — small
delta from different emscripten / closure-compiler versions).
2026-05-31 11:36:46 +02:00
..
hive-c0re.nix hivectl: add operator-facing host CLI with forge + matrix create-user verbs (#655) 2026-05-30 20:34:59 +02:00
hive-forge.nix nix: add breaking-change note to each openFirewall description (argus #653) 2026-05-30 19:30:11 +02:00
hive-gateway.nix nix/hive-gateway: stop SPA fallback from masking missing /matrix/ assets (#643) 2026-05-31 01:35:17 +02:00
hive-matrix.nix nix/hive-matrix: build Imaging.{js,wasm} from source via emscripten (#685, mara feedback) 2026-05-31 11:36:46 +02:00