From 39c824472cf7930f15f065a5896fbed70d369f65 Mon Sep 17 00:00:00 2001 From: 81reap Date: Wed, 28 Oct 2026 15:18:51 -0400 Subject: [PATCH] fix(nix) :: build the browser assets in every cargo gate build.rs embeds the browser assets, so on a fresh checkout `nix run .#lint-rust` and `nix run .#test-rust` stop with "The browser assets are built by npm". Now all tests build the browser assets first just like `test-browser`. --- flake.nix | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index def67e212..29a7caa7c 100644 --- a/flake.nix +++ b/flake.nix @@ -93,12 +93,18 @@ # odbc-sys links against a driver manager, and the C sources vendored by # aws-lc-sys, libsqlite3-sys and zstd-sys need a compiler. Nothing here - # reaches for OpenSSL: SQLPage speaks TLS through rustls. + # reaches for OpenSSL: SQLPage speaks TLS through rustls. build.rs embeds + # the browser assets, so every cargo gate builds them with npm first. cargoRuntime = pkgs: [ (rustToolchainFor pkgs) pkgs.stdenv.cc pkgs.unixodbc + pkgs.nodejs_26 ]; + buildBrowserAssets = '' + npm ci --ignore-scripts + npm run build + ''; # The database matrix runs prebuilt test binaries that link the unixODBC # driver manager statically. It still reads ODBCSYSINI at run time and # dlopens whatever absolute path this file names, so pointing that one @@ -157,6 +163,9 @@ env = cargoEnv pkgs; script = '' cargo fmt --all -- --check + '' + + buildBrowserAssets + + '' cargo clippy --all-targets --all-features -- -D warnings ''; }; @@ -165,18 +174,16 @@ description = "Run the Rust test suites against DATABASE_URL, or SQLite when it is unset"; packages = cargoRuntime pkgs; env = cargoEnv pkgs; - script = '' + script = buildBrowserAssets + '' cargo test "$@" ''; }; test-browser = { description = "Drive the components in a browser with Playwright"; - packages = [ pkgs.nodejs_26 ] ++ cargoRuntime pkgs; + packages = cargoRuntime pkgs; env = cargoEnv pkgs // playwrightEnv pkgs; - script = '' - npm ci --ignore-scripts - npm run build + script = buildBrowserAssets + '' cd tests/end-to-end npx playwright test "$@" ''; @@ -223,7 +230,6 @@ (with pkgs; [ biome hurl - nodejs_26 pkg-config sqlite ])