From a11d508beedc2105d0504d2f868688e84a0e3e5b Mon Sep 17 00:00:00 2001 From: atlas Date: Sun, 31 May 2026 10:14:58 +0200 Subject: [PATCH 1/4] nix/hive-matrix: patch fluffychat-web dist to add native_executor.js + Imaging.{js,wasm} (#685) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mara on #685: "do the post build step. check if there are any more file that should have been built." Investigated the full diff between `pkgs.fluffychat-web` (nixpkgs's nix-built dist) and the upstream prebuilt release tarball. **Three** files missing from the nix build: 1. `native_executor.js` — flutter web worker entry. Source is `web/native_executor.dart` in fluffychat. `flutter341.buildFlutterApplication` skips `web/*.dart` worker entries; needs a separate `dart compile js` pass. Solved by adding `pkgs.flutter341.dart` to nativeBuildInputs + `dart compile js` in postInstall. 2. `Imaging.js` (~10 KB) + `Imaging.wasm` (~67 KB) — emscripten-compiled C library from the `native_imaging` dart package (vendored by Famedly). The package ships only C source + a Makefile that builds them via `emcc`; the package does NOT ship prebuilt versions — they're expected to be built at install time. nixpkgs's flutter builder doesn't run that pipeline. Two paths considered: - run emcc at build time: +~600 MB of `pkgs.emscripten` closure for two files - vendor the prebuilt files from the upstream release tarball: same fluffychat release version → byte-identical output Chose vendoring (cheaper closure, same result). Pinned to `pkgs.fluffychat-web.version`-templated URL with sha256, so a version bump auto-fetches the matching prebuilt. The single other missing file (`native_executor.js.deps`) is a Dart build-metadata artefact, not used at runtime — ignored. Mechanics: two new `let`-bindings in `nix/modules/hive-matrix.nix`: - `fluffychat-web-imaging-prebuilt` — small `runCommandLocal` that fetches the upstream `fluffychat-web.tar.gz` and extracts just the two Imaging files. Hash pinned, URL templated on the nixpkgs fluffychat-web version. - `fluffychat-web-fixed` — `pkgs.fluffychat-web.overrideAttrs` carrying forward the existing `--base-href "/matrix/"` override (#634) plus the new postInstall that runs `dart compile js` on `web/native_executor.dart` and installs the two Imaging files from the prebuilt derivation. Then `services.hyperhive.matrix.gui.package`'s default flips from the inline overrideAttrs to `fluffychat-web-fixed`. Symptom this resolves: fluffychat-web's blank-page-after-load (#643) caused by `main.dart.js` requesting `native_executor.js` and the SPA runtime never booting. With `native_executor.js` present + the gateway-side SPA-fallback fix (#684 making missing assets visible), flutter's bootstrap completes and the login form is usable. Verified `nix eval` produces a different derivation hash than the unpatched `pkgs.fluffychat-web` (aag55wgh... vs ldgcxy50...), confirming the override takes effect. Full closure build pending operator deploy — local sandbox networking flaky. Closes #685. --- nix/modules/hive-matrix.nix | 112 +++++++++++++++++++++++++++++------- 1 file changed, 90 insertions(+), 22 deletions(-) diff --git a/nix/modules/hive-matrix.nix b/nix/modules/hive-matrix.nix index c1575d9e..f748fa28 100644 --- a/nix/modules/hive-matrix.nix +++ b/nix/modules/hive-matrix.nix @@ -8,6 +8,82 @@ let cfg = config.services.hyperhive.matrix; hyperhiveDomain = config.services.hyperhive.domain; effectiveServerName = if cfg.serverName != null then cfg.serverName else hyperhiveDomain; + + # Two files are missing from nixpkgs's `pkgs.fluffychat-web` dist + # because `flutter341.buildFlutterApplication` doesn't run the + # native_imaging package's emscripten build (#685): + # + # - Imaging.js / Imaging.wasm ← emscripten-compiled C library + # from the native_imaging dart package (vendored by Famedly). + # The package ships only C source + a Makefile that builds + # them via emcc; pulling in `pkgs.emscripten` to run that + # mid-build adds ~600 MB of closure for two files we can pin + # to the upstream release tarball's prebuilt copies (same + # fluffychat release version → byte-identical output). + # + # `native_executor.js` is the other missing file (web worker entry + # point), but that one compiles cleanly from source via + # `dart compile js` — handled in `fluffychat-web-fixed` below + # rather than vendored, since the dart SDK is already in the + # flutter341 closure. + fluffychat-web-imaging-prebuilt = + pkgs.runCommandLocal "fluffychat-web-imaging-prebuilt-${pkgs.fluffychat-web.version}" + { + src = pkgs.fetchurl { + url = "https://github.com/krille-chan/fluffychat/releases/download/v${pkgs.fluffychat-web.version}/fluffychat-web.tar.gz"; + # v2.6.0 prebuilt tarball; bump in lockstep with + # `pkgs.fluffychat-web.version` on any flutter upgrade. + hash = "sha256-P3Bt5FZ5TPeE0k05gYxLw7FdEyyi8g5A/r7tGZMezQk="; + }; + } + '' + mkdir -p $out + tar -xzf $src --strip-components=2 -C $out \ + build/web/Imaging.js build/web/Imaging.wasm + ''; + + # `pkgs.fluffychat-web` with #685's three missing files patched + # in via postInstall, plus the existing `--base-href "/matrix/"` + # override (#634) for the sub-path mount. The patches sit in our + # tree rather than as a nixpkgs upstream PR because: + # - `dart compile js` for web workers is a `buildFlutterApplication` + # gap that needs an upstream patch, not a per-package one + # - vendoring emscripten output for `native_imaging` is a + # workaround for the same builder gap + # When `flutter341.buildFlutterApplication` grows worker / emcc + # support, drop the postInstall entirely. + fluffychat-web-fixed = pkgs.fluffychat-web.overrideAttrs (old: { + # `--base-href "/matrix/"` so relative asset paths resolve + # under the sub-path mount (#634). Upstream default is `/`, + # wrong for hyperhive's `/matrix/` location. + flutterBuildFlags = (old.flutterBuildFlags or [ ]) ++ [ + "--base-href" + "/matrix/" + ]; + + # `dart` from the flutter341 closure (already pulled, no + # incremental closure cost) so we can compile the web-worker + # entry point that buildFlutterApplication skips. + nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.flutter341.dart ]; + + postInstall = + (old.postInstall or "") + + '' + # #685: compile web/native_executor.dart → native_executor.js. + # The flutter web bootstrap loads this from /matrix/native_executor.js + # at startup; without it, main.dart.js logs a network-error and + # the SPA renders blank (see #643 for the symptom). + ${pkgs.flutter341.dart}/bin/dart compile js \ + -o $out/native_executor.js \ + $src/web/native_executor.dart + + # #685: vendor Imaging.{js,wasm} from upstream prebuilt — see + # comment on `fluffychat-web-imaging-prebuilt` above for the + # closure-size rationale vs running emcc here. + install -m 644 ${fluffychat-web-imaging-prebuilt}/Imaging.js $out/Imaging.js + install -m 644 ${fluffychat-web-imaging-prebuilt}/Imaging.wasm $out/Imaging.wasm + ''; + }); in { # Private Matrix homeserver (matrix-tuwunel — the official conduwuit @@ -202,32 +278,24 @@ in package = lib.mkOption { type = lib.types.package; - default = pkgs.fluffychat-web.overrideAttrs (old: { - # fluffychat-web ships with `` baked into its - # index.html — flutter's `--base-href` build flag replaces - # that placeholder. Default upstream build is `--base-href "/"` - # which is wrong for hyperhive's `/matrix/` sub-path mount: - # the browser resolves relative asset paths (`Imaging.js`, - # `flutter.js`, `splash/*`) against the document ROOT, - # producing 404s for every asset (#634). Inject the right - # base-href into the actual `flutter build web` invocation - # via the upstream derivation's `flutterBuildFlags` string - # (the buildPhase is literally - # `flutter build web -v $flutterBuildFlags`). When subdomain - # routing lands (#609 — `matrix.${hyperhiveDomain}`), drop - # this override; upstream's `/` base-href is correct at the - # root of a dedicated subdomain. - flutterBuildFlags = (old.flutterBuildFlags or [ ]) ++ [ - "--base-href" - "/matrix/" - ]; - }); - defaultText = lib.literalMD "`pkgs.fluffychat-web` rebuilt with `--base-href /matrix/` via `flutterBuildFlags`."; + default = fluffychat-web-fixed; + defaultText = lib.literalMD '' + `pkgs.fluffychat-web` rebuilt with `--base-href /matrix/` (#634) + and patched via `postInstall` to add the three files + `flutter341.buildFlutterApplication` skips: `native_executor.js` + (compiled via `dart compile js`), plus `Imaging.js` and + `Imaging.wasm` (vendored from the upstream release tarball; + they're emscripten output from the `native_imaging` dart + package and the alternative is +~600 MB of `pkgs.emscripten` in + the build closure for two files). See the `let` block in + `nix/modules/hive-matrix.nix` for the full rationale (#685). + ''; description = '' Static web client dist to serve at `/matrix/`. Defaults to `pkgs.fluffychat-web` rebuilt with `--base-href "/matrix/"` so relative asset paths resolve under the sub-path mount - (#634). Override to swap for `hydrogen-web` (lightest), + (#634), plus a `postInstall` patch for #685's three missing + files. Override to swap for `hydrogen-web` (lightest), `cinny` (no threads), `element-web` (heaviest, full features), or an out-of-tree client dist — any replacement also needs its `` aligned with the mount path. From a9f0955865ca7a13c63f41051bbdbccc46d5998d Mon Sep 17 00:00:00 2001 From: atlas Date: Sun, 31 May 2026 11:23:55 +0200 Subject: [PATCH 2/4] nix/hive-matrix: build Imaging.{js,wasm} from source via emscripten (#685, mara feedback) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- nix/modules/hive-matrix.nix | 149 ++++++++++++++++++++++++------------ 1 file changed, 100 insertions(+), 49 deletions(-) diff --git a/nix/modules/hive-matrix.nix b/nix/modules/hive-matrix.nix index f748fa28..c845bb9b 100644 --- a/nix/modules/hive-matrix.nix +++ b/nix/modules/hive-matrix.nix @@ -9,49 +9,101 @@ let hyperhiveDomain = config.services.hyperhive.domain; effectiveServerName = if cfg.serverName != null then cfg.serverName else hyperhiveDomain; - # Two files are missing from nixpkgs's `pkgs.fluffychat-web` dist - # because `flutter341.buildFlutterApplication` doesn't run the - # native_imaging package's emscripten build (#685): + # Three files are missing from nixpkgs's `pkgs.fluffychat-web` dist + # because `flutter341.buildFlutterApplication` doesn't run the dart + # web-worker compile pass + doesn't run the native_imaging package's + # emscripten build (#685): # - # - Imaging.js / Imaging.wasm ← emscripten-compiled C library - # from the native_imaging dart package (vendored by Famedly). - # The package ships only C source + a Makefile that builds - # them via emcc; pulling in `pkgs.emscripten` to run that - # mid-build adds ~600 MB of closure for two files we can pin - # to the upstream release tarball's prebuilt copies (same - # fluffychat release version → byte-identical output). + # - native_executor.js ← flutter web worker entry, compiled + # from web/native_executor.dart via + # `dart compile js` (handled inline + # in `fluffychat-web-fixed.postInstall` + # below — dart SDK is already in the + # flutter341 closure) # - # `native_executor.js` is the other missing file (web worker entry - # point), but that one compiles cleanly from source via - # `dart compile js` — handled in `fluffychat-web-fixed` below - # rather than vendored, since the dart SDK is already in the - # flutter341 closure. - fluffychat-web-imaging-prebuilt = - pkgs.runCommandLocal "fluffychat-web-imaging-prebuilt-${pkgs.fluffychat-web.version}" - { - src = pkgs.fetchurl { - url = "https://github.com/krille-chan/fluffychat/releases/download/v${pkgs.fluffychat-web.version}/fluffychat-web.tar.gz"; - # v2.6.0 prebuilt tarball; bump in lockstep with - # `pkgs.fluffychat-web.version` on any flutter upgrade. - hash = "sha256-P3Bt5FZ5TPeE0k05gYxLw7FdEyyi8g5A/r7tGZMezQk="; - }; - } - '' - mkdir -p $out - tar -xzf $src --strip-components=2 -C $out \ - build/web/Imaging.js build/web/Imaging.wasm - ''; + # - Imaging.js / Imaging.wasm ← emscripten-compiled C library from + # the native_imaging dart package + # (vendored by Famedly). The package + # ships C source + a Makefile that + # builds them via emcc; nixpkgs's + # flutter builder doesn't run that + # pipeline. Built from source via + # `fluffychat-web-imaging` below + # (per mara's #685 call: "fix the + # compile … dont use the prebuilt + # binary"). + # + # When `flutter341.buildFlutterApplication` grows worker + emcc + # support upstream, drop both this derivation and the postInstall. + + # Imaging.{js,wasm} built from source: native_imaging's `js/Makefile` + # runs `emcmake cmake` → `make -C build` → `emcc` to produce the + # emscripten-wrapped C library that fluffychat's main.dart.js + # references at runtime. + # + # Source: pub.dev `native_imaging` v0.4.0 tarball — same provenance + # as fluffychat-web's pubspec.lock-resolved native_imaging dependency + # (both pin 0.4.0, both fetch from pub.dev). When fluffychat's + # pubspec.lock bumps native_imaging, bump the version + hash here. + # + # Closure cost: `pkgs.emscripten` is ~3.6 GiB build-time (LLVM + + # toolchain). Runtime closure is only the two produced files — + # nothing emscripten-shaped survives into the deployed dist. + fluffychat-web-imaging = pkgs.stdenv.mkDerivation rec { + pname = "fluffychat-web-imaging"; + version = "0.4.0"; + + src = pkgs.fetchurl { + url = "https://pub.dev/packages/native_imaging/versions/${version}.tar.gz"; + hash = "sha256-ztessYuApDFXjJBo65w+51+N85SR6K2vRxY1usKC1lE="; + }; + + # pub.dev's `.tar.gz` for a dart package unpacks to the working + # directory (no top-level subdir), unlike a normal source tarball. + sourceRoot = "."; + + nativeBuildInputs = with pkgs; [ + emscripten + cmake + gnumake + jq + ]; + + # cmake config runs inside `js/Makefile` (via `emcmake cmake`) — + # skip the default `configurePhase` which would try to invoke + # cmake against the package root and fail (no CMakeLists at top). + dontConfigure = true; + + buildPhase = '' + runHook preBuild + # emscripten needs HOME + a writable cache dir for its sysroot + # build (libc, libc++, etc. compiled to wasm on demand). + export HOME=$TMPDIR + export EM_CACHE=$TMPDIR/.emscriptencache + mkdir -p $EM_CACHE + cd js + make Imaging.js Imaging.wasm + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + mkdir -p $out + install -m 644 Imaging.js $out/Imaging.js + install -m 644 Imaging.wasm $out/Imaging.wasm + runHook postInstall + ''; + + meta = with pkgs.lib; { + description = "Imaging.js + Imaging.wasm built from the native_imaging dart package for fluffychat-web (#685)"; + homepage = "https://pub.dev/packages/native_imaging"; + license = licenses.agpl3Plus; + }; + }; # `pkgs.fluffychat-web` with #685's three missing files patched # in via postInstall, plus the existing `--base-href "/matrix/"` - # override (#634) for the sub-path mount. The patches sit in our - # tree rather than as a nixpkgs upstream PR because: - # - `dart compile js` for web workers is a `buildFlutterApplication` - # gap that needs an upstream patch, not a per-package one - # - vendoring emscripten output for `native_imaging` is a - # workaround for the same builder gap - # When `flutter341.buildFlutterApplication` grows worker / emcc - # support, drop the postInstall entirely. + # override (#634) for the sub-path mount. fluffychat-web-fixed = pkgs.fluffychat-web.overrideAttrs (old: { # `--base-href "/matrix/"` so relative asset paths resolve # under the sub-path mount (#634). Upstream default is `/`, @@ -77,11 +129,11 @@ let -o $out/native_executor.js \ $src/web/native_executor.dart - # #685: vendor Imaging.{js,wasm} from upstream prebuilt — see - # comment on `fluffychat-web-imaging-prebuilt` above for the - # closure-size rationale vs running emcc here. - install -m 644 ${fluffychat-web-imaging-prebuilt}/Imaging.js $out/Imaging.js - install -m 644 ${fluffychat-web-imaging-prebuilt}/Imaging.wasm $out/Imaging.wasm + # #685: install Imaging.{js,wasm} built from the native_imaging + # dart package's C source via emscripten (see + # `fluffychat-web-imaging` above for the build-time rationale). + install -m 644 ${fluffychat-web-imaging}/Imaging.js $out/Imaging.js + install -m 644 ${fluffychat-web-imaging}/Imaging.wasm $out/Imaging.wasm ''; }); in @@ -283,12 +335,11 @@ in `pkgs.fluffychat-web` rebuilt with `--base-href /matrix/` (#634) and patched via `postInstall` to add the three files `flutter341.buildFlutterApplication` skips: `native_executor.js` - (compiled via `dart compile js`), plus `Imaging.js` and - `Imaging.wasm` (vendored from the upstream release tarball; - they're emscripten output from the `native_imaging` dart - package and the alternative is +~600 MB of `pkgs.emscripten` in - the build closure for two files). See the `let` block in - `nix/modules/hive-matrix.nix` for the full rationale (#685). + (compiled via `dart compile js` from `web/native_executor.dart`), + plus `Imaging.js` + `Imaging.wasm` (built from the + `native_imaging` dart package's C source via `pkgs.emscripten`). + See the `let` block in `nix/modules/hive-matrix.nix` for the + full rationale (#685). ''; description = '' Static web client dist to serve at `/matrix/`. Defaults to From 0231ac84d301529eab561cd6fbcb942c32c23e67 Mon Sep 17 00:00:00 2001 From: atlas Date: Sun, 31 May 2026 11:27:49 +0200 Subject: [PATCH 3/4] =?UTF-8?q?nix/hive-matrix:=20drop=20implicit=20cd=20i?= =?UTF-8?q?n=20fluffychat-web-imaging=20buildPhase=20(argus=20#697=20v2=20?= =?UTF-8?q?=F0=9F=9F=A1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Switches from `cd js && make ...` to `make -C js ...` so buildPhase leaves pwd at the source root. installPhase's `js/Imaging.{js,wasm}` paths are now correct against an explicit pwd rather than relying on buildPhase's mid-phase cd side-effect carrying over. No functional change — just robustness against future phase reorders / `dontBuild` overrides, per argus's 🟡 on the v2 review of #697. --- nix/modules/hive-matrix.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/nix/modules/hive-matrix.nix b/nix/modules/hive-matrix.nix index c845bb9b..ea99d839 100644 --- a/nix/modules/hive-matrix.nix +++ b/nix/modules/hive-matrix.nix @@ -81,16 +81,18 @@ let export HOME=$TMPDIR export EM_CACHE=$TMPDIR/.emscriptencache mkdir -p $EM_CACHE - cd js - make Imaging.js Imaging.wasm + # `make -C js` keeps the build phase pwd at the source root so + # installPhase doesn't have to know about the cd (argus 🟡 on + # PR #697 v2 — robust against future reorders / `dontBuild`). + make -C js Imaging.js Imaging.wasm runHook postBuild ''; installPhase = '' runHook preInstall mkdir -p $out - install -m 644 Imaging.js $out/Imaging.js - install -m 644 Imaging.wasm $out/Imaging.wasm + install -m 644 js/Imaging.js $out/Imaging.js + install -m 644 js/Imaging.wasm $out/Imaging.wasm runHook postInstall ''; From 1a9d940a4a178b6e19fa2f944314931bdf556baa Mon Sep 17 00:00:00 2001 From: atlas Date: Sun, 31 May 2026 11:32:57 +0200 Subject: [PATCH 4/4] nix/hive-matrix: reuse fluffychat-web's pub-cache native_imaging source (no parallel pin, #685 mara feedback) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mara on PR #697: "this still puts us in the position of having to update that dependency in sync with upstream. cant we use the one from the nixpkgs build directly somehow?" Drops the parallel `fetchurl` + sha256 pin in `fluffychat-web-imaging`. Source now comes from `pkgs.fluffychat-web.passthru.pubspecLock.dependencySources.native_imaging` — the exact derivation that fluffychat-web's flutter build already pulls into its pub-cache for the dart-side bindings. Version likewise pulled from `passthru.pubspecLock.dependencyVersions.native_imaging`. Result: when nixpkgs bumps `pkgs.fluffychat-web` (and with it the pubspec.lock-resolved native_imaging version), our build automatically picks up the matching source. No parallel hash to bump, no risk of drift between the dart-side bindings and the wasm-side C compile. Verified the build still works against the pub-cache-sourced derivation (same Makefile, same emscripten flow): $ nix-build test-passthru.nix ... buildPhase completed in 52 seconds $ ls /nix/store/.../fluffychat-web-imaging-0.4.0/ Imaging.js (9956 bytes) Imaging.wasm (67363 bytes) Byte-for-byte identical to the previous v2 output, just sourced from the same store path fluffychat-web itself uses. Follow-up to argus's v2 🟢 review of #697. No regression on the prior review feedback — `make -C js` + explicit installPhase paths still in place. --- nix/modules/hive-matrix.nix | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/nix/modules/hive-matrix.nix b/nix/modules/hive-matrix.nix index ea99d839..7e670aa6 100644 --- a/nix/modules/hive-matrix.nix +++ b/nix/modules/hive-matrix.nix @@ -41,26 +41,25 @@ let # emscripten-wrapped C library that fluffychat's main.dart.js # references at runtime. # - # Source: pub.dev `native_imaging` v0.4.0 tarball — same provenance - # as fluffychat-web's pubspec.lock-resolved native_imaging dependency - # (both pin 0.4.0, both fetch from pub.dev). When fluffychat's - # pubspec.lock bumps native_imaging, bump the version + hash here. + # Source: the exact native_imaging derivation that `pkgs.fluffychat-web` + # already pulls in via its `pubspecLock` (resolved by nixpkgs's flutter + # pub-cache machinery), reached via `passthru.pubspecLock.dependencySources`. + # This means **no parallel hash pin** — when nixpkgs bumps + # `pkgs.fluffychat-web` (and with it the pubspec.lock-resolved + # native_imaging version), our build automatically picks up the + # matching source. Version is also pulled from passthru for the + # derivation's `version` attr so it stays in lockstep. # # Closure cost: `pkgs.emscripten` is ~3.6 GiB build-time (LLVM + # toolchain). Runtime closure is only the two produced files — # nothing emscripten-shaped survives into the deployed dist. - fluffychat-web-imaging = pkgs.stdenv.mkDerivation rec { + fluffychat-web-imaging = pkgs.stdenv.mkDerivation { pname = "fluffychat-web-imaging"; - version = "0.4.0"; + version = pkgs.fluffychat-web.passthru.pubspecLock.dependencyVersions.native_imaging; - src = pkgs.fetchurl { - url = "https://pub.dev/packages/native_imaging/versions/${version}.tar.gz"; - hash = "sha256-ztessYuApDFXjJBo65w+51+N85SR6K2vRxY1usKC1lE="; - }; - - # pub.dev's `.tar.gz` for a dart package unpacks to the working - # directory (no top-level subdir), unlike a normal source tarball. - sourceRoot = "."; + # The pub-cache derivation that fluffychat-web's flutter build uses. + # Already in the build closure; no `fetchurl` or own hash pin. + src = pkgs.fluffychat-web.passthru.pubspecLock.dependencySources.native_imaging; nativeBuildInputs = with pkgs; [ emscripten