From 7647969d49418bc2a6a5725159cea69516c55492 Mon Sep 17 00:00:00 2001 From: atlas Date: Sun, 31 May 2026 12:11:54 +0200 Subject: [PATCH] nix/hive-matrix: run dart compile js from build CWD so package_config resolves (#685 fixup) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mara's first deploy hit: Error: Couldn't resolve the package 'matrix' in 'package:matrix/matrix.dart'. /nix/store/k9j8ns45fz7rpjp6rzk33ydjng67pgm0-source/web/native_executor.dart:1:8: Error: Not found: 'package:matrix/matrix.dart' Root cause: `dart compile js` walks up from the source file's dir to find `.dart_tool/package_config.json`. My previous postInstall passed `$src/web/native_executor.dart` — pointing dart at the unpacked nix source, which has no `.dart_tool/` (pub-get wrote it to the build CWD, not the read-only store path). Fix: use a relative path `web/native_executor.dart`. nixpkgs's buildFlutterApplication leaves CWD at the source root in postInstall (its installPhase is just `cp -r build/web "$out"` with no `cd` first — see `pkgs/development/compilers/flutter/build-support/ build-flutter-application.nix`), so the relative path walks up from `web/` to the build CWD where pub-get's package_config lives. Verified by `nix eval`; full closure build pending operator deploy. Followup to #697 (the original fix; merged but mara's deploy then surfaced this regression). --- nix/modules/hive-matrix.nix | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/nix/modules/hive-matrix.nix b/nix/modules/hive-matrix.nix index 7e670aa6..fe631815 100644 --- a/nix/modules/hive-matrix.nix +++ b/nix/modules/hive-matrix.nix @@ -126,9 +126,26 @@ let # 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). + # + # `dart compile js` needs `.dart_tool/package_config.json` to + # resolve `package:matrix/...` and the rest of fluffychat's + # `pubspec.lock` deps. buildFlutterApplication's pub-get step + # writes that file to the build CWD (the unpacked source dir), + # not to `$src` (the read-only nix store path). So we must use + # a relative path that walks up from `web/` to the build CWD + # where pub-get's package_config lives — pointing at + # `$src/web/native_executor.dart` walks up to `$src/`, finds + # no `.dart_tool/`, and fails with `Couldn't resolve the + # package 'matrix'` (mara's first build attempt on #685). + # + # nixpkgs's buildFlutterApplication leaves CWD at the source + # root for postInstall (see `pkgs/development/compilers/flutter/ + # build-support/build-flutter-application.nix` — installPhase + # is `cp -r build/web "$out"` with no `cd` first). So `web/...` + # resolves correctly here. ${pkgs.flutter341.dart}/bin/dart compile js \ -o $out/native_executor.js \ - $src/web/native_executor.dart + web/native_executor.dart # #685: install Imaging.{js,wasm} built from the native_imaging # dart package's C source via emscripten (see