From 32935535b7a92db446633856efd0e357df0feeea Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sun, 22 Nov 2026 09:22:17 -0600 Subject: [PATCH 1/9] reuse ID dependencies and slim Nix checks --- pkgs/id/flake.nix | 311 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 272 insertions(+), 39 deletions(-) diff --git a/pkgs/id/flake.nix b/pkgs/id/flake.nix index 26d9efc1a5..6539a3044b 100644 --- a/pkgs/id/flake.nix +++ b/pkgs/id/flake.nix @@ -46,6 +46,9 @@ # Root runtime packages can skip duplicate tests; named flake checks # keep the same coverage. Standalone builds remain checked by default. checkRuntimePackages = args.checkRuntimePackages or true; + # The root flake injects its pinned Crane input for NixOS runtime + # builds; standalone ID flakes keep their existing package builder. + craneInput = args.crane or null; in flake-utils.lib.eachDefaultSystem ( system: @@ -70,6 +73,38 @@ ; inherit (nixCommon) nativeBuildInputs; + # Check derivations use focused tool closures instead of the full + # development shell (which includes Playwright browsers, deployment + # tools, and unrelated Cargo utilities). + checkBaseNativeBuildInputs = with pkgs; [ + bash + coreutils + diffutils + findutils + gnugrep + gnused + gawk + git + jq + just + ]; + checkCargoNativeBuildInputs = [ + pkgs.pkg-config + pkgs.cmake + pkgs.cargo-nextest + ]; + checkWebNativeBuildInputs = [ pkgs.bun ]; + checkRocNativeBuildInputs = [ + rocCompiler + pkgs.zig_0_16 + ]; + + craneLib = + if craneInput == null then + null + else + (craneInput.mkLib pkgs).overrideToolchain rustToolchain; + # Pre-fetch cargo dependencies for sandbox builds (no network access) cargoDeps = pkgs.rustPlatform.importCargoLock { lockFile = ./Cargo.lock; @@ -80,6 +115,55 @@ }; }; + # Root runtime packages use Crane's separate dependency derivation so + # source-only changes rebuild the ID workspace without recompiling its + # registry/git dependencies. Standalone checked packages keep the + # established buildRustPackage path below. + mkCraneRuntime = + { + pname, + cargoExtraArgs, + nativeBuildInputs, + buildInputs ? [ pkgs.openssl ], + meta, + buildArgs ? { }, + }: + let + commonArgs = { + inherit pname cargoExtraArgs; + version = "0.1.0"; + src = ./.; + strictDeps = true; + inherit buildInputs; + # The dependency derivation needs the same native tools and + # OpenSSL metadata as the runtime compile, but not web assets. + nativeBuildInputs = [ + pkgs.pkg-config + pkgs.cmake + rustToolchain + ]; + env = { + inherit (opensslEnv) + OPENSSL_DIR + OPENSSL_LIB_DIR + OPENSSL_INCLUDE_DIR + PKG_CONFIG_PATH + ; + }; + # Runtime builds deliberately omit test artifacts; named checks + # below continue to compile and run their own test targets. + doCheck = false; + }; + cargoArtifacts = craneLib.buildDepsOnly commonArgs; + in + craneLib.buildPackage ( + commonArgs + // { + inherit cargoArtifacts buildInputs nativeBuildInputs meta; + } + // buildArgs + ); + # Pre-fetch bun dependencies for sandbox builds (no network access) bun2nixPkg = bun2nix.packages.${system}.default; bunDeps = bun2nixPkg.fetchBunDeps { @@ -97,7 +181,11 @@ name = "id-integration-test-runner"; src = ./.; inherit buildInputs; - nativeBuildInputs = nativeBuildInputs ++ [ + nativeBuildInputs = [ + rustToolchain + pkgs.pkg-config + pkgs.cmake + pkgs.bun bun2nixPkg.hook pkgs.rustPlatform.cargoSetupHook ]; @@ -172,9 +260,62 @@ targets = [ "wasm32-unknown-unknown" ]; }; - # Helper to create a check that runs a just command or direct test - # command, with an optional pre-check step and check-specific tools. + # Helpers keep each check's derivation focused on the tools and + # generated assets it actually consumes. Full CI checks retain the + # defaults; static, native-shell, and web-only checks avoid building + # unrelated Cargo, Bun, and Roc artifacts. mkCheck = name: justCmd: mkCheckWith { inherit name justCmd; }; + mkCheckLean = + name: justCmd: + mkCheckWith { + inherit name justCmd; + needsCargoSetup = false; + needsRustToolchain = false; + needsBuildInputs = false; + installWebDeps = false; + buildWebAssets = false; + compileRocWorldHost = false; + }; + mkCheckRustOnly = + name: justCmd: + mkCheckWith { + inherit name justCmd; + needsCargoSetup = false; + needsBuildInputs = false; + installWebDeps = false; + buildWebAssets = false; + compileRocWorldHost = false; + }; + mkCheckBiome = + name: justCmd: + mkCheckWith { + inherit name justCmd; + needsCargoSetup = false; + needsRustToolchain = false; + needsBuildInputs = false; + installWebDeps = false; + buildWebAssets = false; + compileRocWorldHost = false; + extraNativeBuildInputs = [ pkgs.biome ]; + }; + mkCheckCargoOnly = + name: justCmd: + mkCheckWith { + inherit name justCmd; + installWebDeps = false; + buildWebAssets = false; + compileRocWorldHost = false; + }; + mkCheckWebOnly = + name: justCmd: + mkCheckWith { + inherit name justCmd; + needsCargoSetup = false; + needsRustToolchain = false; + needsBuildInputs = false; + buildWebAssets = false; + compileRocWorldHost = false; + }; mkCheckWith = { @@ -183,8 +324,14 @@ checkCommand ? null, extraNativeBuildInputs ? [ ], beforeCheck ? "", + needsCargoSetup ? true, + needsRustToolchain ? true, + needsBuildInputs ? true, + installWebDeps ? true, + buildWebAssets ? true, + compileRocWorldHost ? true, }: - pkgs.stdenv.mkDerivation { + pkgs.stdenv.mkDerivation ({ name = "id-${name}"; # Every check builds its own debug test binaries in parallel on a # runner with limited disk. Full debuginfo and the incremental cache @@ -197,24 +344,23 @@ # shebang in the sandbox, where /bin/sh does not exist (#5926). ID_TEST_FAKE_SH = "${pkgs.stdenv.shell}"; src = ./.; - inherit buildInputs; + buildInputs = if needsBuildInputs then buildInputs else [ ]; nativeBuildInputs = - nativeBuildInputs - ++ extraNativeBuildInputs - ++ [ - bun2nixPkg.hook - pkgs.rustPlatform.cargoSetupHook - ]; - inherit cargoDeps; + checkBaseNativeBuildInputs + ++ pkgs.lib.optionals needsRustToolchain [ rustToolchain ] + ++ pkgs.lib.optionals needsCargoSetup ( + checkCargoNativeBuildInputs ++ [ pkgs.rustPlatform.cargoSetupHook ] + ) + ++ pkgs.lib.optionals installWebDeps ( + checkWebNativeBuildInputs ++ [ bun2nixPkg.hook ] + ) + ++ pkgs.lib.optionals compileRocWorldHost checkRocNativeBuildInputs + ++ extraNativeBuildInputs; inherit (opensslEnv) OPENSSL_DIR; inherit (opensslEnv) OPENSSL_LIB_DIR; inherit (opensslEnv) OPENSSL_INCLUDE_DIR; inherit (opensslEnv) PKG_CONFIG_PATH; - # bun2nix hook: install web deps offline via pre-fetched cache - inherit bunDeps; - bunRoot = "web"; - bunInstallFlags = [ "--linker=hoisted" ]; dontUseBunBuild = true; dontUseBunCheck = true; dontUseBunInstall = true; @@ -224,13 +370,15 @@ export HOME=$(mktemp -d) export CARGO_HOME=$HOME/.cargo - # @tailwindcss/cli uses @parcel/watcher (native module) which needs libstdc++ - export LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + ${if buildWebAssets then '' + # @tailwindcss/cli uses @parcel/watcher (native module) which needs libstdc++ + export LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" - # Build web assets (bun2nix hook already installed node_modules via bunNodeModulesInstallPhase) - (cd web && bun run build) + # Build web assets (bun2nix hook installed node_modules). + (cd web && bun run build) + '' else ""} - ${buildWasmHost} + ${if compileRocWorldHost then buildWasmHost else ""} ${beforeCheck} @@ -240,7 +388,13 @@ mkdir -p $out echo "${name} passed at $(date)" > $out/result.txt ''; - }; + } + // pkgs.lib.optionalAttrs needsCargoSetup { inherit cargoDeps; } + // pkgs.lib.optionalAttrs installWebDeps { + inherit bunDeps; + bunRoot = "web"; + bunInstallFlags = [ "--linker=hoisted" ]; + }); # Helper to create a script that runs in the project directory mkScript = @@ -365,22 +519,22 @@ default = mkCheck "ci" "ci"; # Individual checks - cargo-fmt-check = mkCheck "cargo-fmt-check" "cargo-fmt-check"; - web-fmt-check = mkCheck "web-fmt-check" "web-fmt-check"; + cargo-fmt-check = mkCheckRustOnly "cargo-fmt-check" "cargo-fmt-check"; + web-fmt-check = mkCheckBiome "web-fmt-check" "web-fmt-check"; clippy-lint = mkCheck "clippy-lint" "clippy-lint"; # id-native-shell gate (#5582): the crate is a non-default # workspace member, invisible to the default-member checks. - clippy-native-shell = mkCheck "clippy-native-shell" "clippy-native-shell"; - web-lint = mkCheck "web-lint" "web-lint"; + clippy-native-shell = mkCheckCargoOnly "clippy-native-shell" "clippy-native-shell"; + web-lint = mkCheckBiome "web-lint" "web-lint"; test = mkCheck "test" "test-sandbox"; test-unit = mkCheck "test-unit" "test-unit"; test-crate-integration = mkCheck "test-crate-integration" "test-crate-integration"; - test-native-shell = mkCheck "test-native-shell" "test-native-shell"; + test-native-shell = mkCheckCargoOnly "test-native-shell" "test-native-shell"; # Rust example guests (#7904): plaza-sdk (examples/rust-world) # and rust-counter (examples/rust-counter) are standalone # crates outside the pkgs/id workspace, so no workspace test # check ever ran their unit tests (9 + 2). - test-rust-examples = mkCheck "test-rust-examples" "test-rust-examples"; + test-rust-examples = mkCheckCargoOnly "test-rust-examples" "test-rust-examples"; # Rebuild the Rust counter guest from source and run the # sandbox tests against the rebuilt module (#7904) -- the # roc-examples pattern. Wasm bytes are not reproducible @@ -392,6 +546,8 @@ # tests that load it (src/sandbox.rs include_bytes!). rust-counter-wasm = mkCheckWith { name = "rust-counter-wasm"; + installWebDeps = false; + buildWebAssets = false; beforeCheck = '' export PATH="${rustToolchainWasm}/bin:$PATH" bash examples/rust-counter/build.sh @@ -419,17 +575,29 @@ test-shard-2 = mkCheck "test-shard-2" "test-shard-sandbox 2 4"; test-shard-3 = mkCheck "test-shard-3" "test-shard-sandbox 3 4"; test-web = mkCheck "test-web" "test-web-sandbox"; - test-web-unit = mkCheck "test-web-unit" "test-web-unit"; - test-web-typecheck = mkCheck "test-web-typecheck" "test-web-typecheck"; + test-web-unit = mkCheckWebOnly "test-web-unit" "test-web-unit"; + test-web-typecheck = mkCheckWebOnly "test-web-typecheck" "test-web-typecheck"; # Roc library expect() tests (#813): runs the roc-test just # recipe with the pinned nightly from nix/roc.nix (already in # nativeBuildInputs); fails on a missing compiler or a failing # expect — the world_compile.rs skip path is not reused here. - roc-test = mkCheck "roc-test" "roc-test"; + roc-test = mkCheckWith { + name = "roc-test"; + needsCargoSetup = false; + needsRustToolchain = false; + needsBuildInputs = false; + installWebDeps = false; + buildWebAssets = false; + compileRocWorldHost = false; + extraNativeBuildInputs = [ rocCompiler ]; + justCmd = "roc-test"; + }; # Rebuild all checked-in Roc examples with the pinned compiler, then # run the sandbox behavior and fuel-budget tests against them. roc-examples = mkCheckWith { name = "roc-examples"; + installWebDeps = false; + buildWebAssets = false; checkCommand = '' cargo test --no-default-features --features sandbox,world --lib sandbox cargo test --test toolchain_pin @@ -445,14 +613,14 @@ bash scripts/rebuild-roc-examples.sh ''; }; - doc = mkCheck "doc" "doc"; + doc = mkCheckCargoOnly "doc" "doc"; cargo-check = mkCheck "cargo-check" "cargo-check"; # Production module-size guard (#1411): fails when any # production .rs file exceeds 2,500 production lines. # src/web/markdown.rs was the last id grandfather entry; its # split into web/markdown/ submodules landed under #4704 and # the entry was removed there, completing #1438. - prod-lines-check = mkCheck "prod-lines-check" "prod-lines-check"; + prod-lines-check = mkCheckLean "prod-lines-check" "prod-lines-check"; crash-gate = mkCheck "crash-gate" "crash-gate"; # PR-gate splits of crash-gate (#551): the aggregate above runs # every heavy full sweep serially (~15 min, the slowest PR @@ -469,7 +637,7 @@ # semantic recipe fields. The recipe projects out generation # noise (absolute source path, body serialisation), so this is # green on any correctly regenerated file. - just-recipes-drift = mkCheck "just-recipes-drift" "just-recipes-check && bash scripts/just-recipes-check-test.sh"; + just-recipes-drift = mkCheckLean "just-recipes-drift" "just-recipes-check && bash scripts/just-recipes-check-test.sh"; # Planted-bug mutation proof (#8037, plan #1395): the script # plants one named mutation at a time and requires the @@ -503,6 +671,12 @@ # variant-specific regression fails here instead of in a just recipe. build-sh-test = mkCheckWith { name = "build-sh-test"; + needsRustToolchain = false; + needsCargoSetup = false; + needsBuildInputs = false; + installWebDeps = false; + buildWebAssets = false; + compileRocWorldHost = false; checkCommand = "bash scripts/build-sh-test.sh"; }; @@ -574,7 +748,11 @@ name = "id-test-e2e"; src = ./.; inherit buildInputs; - nativeBuildInputs = nativeBuildInputs ++ [ + nativeBuildInputs = [ + rustToolchain + pkgs.pkg-config + pkgs.cmake + pkgs.bun bun2nixPkg.hook pkgs.rustPlatform.cargoSetupHook # TODO: Switch back to `bunx playwright test` once Bun supports Playwright's @@ -838,7 +1016,42 @@ # ======================================================================= packages = { # Web-enabled package (primary product) - id-web = pkgs.rustPlatform.buildRustPackage { + id-web = + if craneLib != null && !checkRuntimePackages then + mkCraneRuntime { + pname = "id"; + cargoExtraArgs = "--locked -p id --features web,sandbox,ssh,world"; + nativeBuildInputs = [ + pkgs.pkg-config + pkgs.cmake + rustToolchain + pkgs.bun + bun2nixPkg.hook + rocCompiler + ]; + buildArgs = { + inherit bunDeps; + bunRoot = "web"; + bunInstallFlags = [ "--linker=hoisted" ]; + dontUseBunBuild = true; + dontUseBunCheck = true; + dontUseBunInstall = true; + dontUseCmakeConfigure = true; + preBuild = '' + # @tailwindcss/cli uses @parcel/watcher (native module) and needs libstdc++. + export LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + cd web + bun run build + cd .. + ${buildWasmHost} + ''; + }; + meta = commonMeta // { + description = "A peer-to-peer file sharing CLI built with Iroh (with web UI)"; + }; + } + else + pkgs.rustPlatform.buildRustPackage { pname = "id"; version = "0.1.0"; src = ./.; @@ -858,7 +1071,7 @@ }; }; - inherit buildInputs; + buildInputs = [ pkgs.openssl ]; nativeBuildInputs = [ pkgs.pkg-config pkgs.cmake @@ -912,7 +1125,27 @@ }; # Library-only package (no web UI, no bun required) - id-lib = pkgs.rustPlatform.buildRustPackage { + id-lib = + if craneLib != null && !checkRuntimePackages then + mkCraneRuntime { + pname = "id-lib"; + cargoExtraArgs = "--locked -p id --no-default-features --features sandbox,world"; + nativeBuildInputs = [ + pkgs.pkg-config + pkgs.cmake + rustToolchain + rocCompiler + ]; + buildArgs = { + dontUseCmakeConfigure = true; + preBuild = buildWasmHost; + }; + meta = commonMeta // { + description = "A peer-to-peer file sharing CLI built with Iroh"; + }; + } + else + pkgs.rustPlatform.buildRustPackage { pname = "id-lib"; version = "0.1.0"; src = ./.; @@ -932,7 +1165,7 @@ ]; dontUseCmakeConfigure = true; - inherit buildInputs; + buildInputs = [ pkgs.openssl ]; nativeBuildInputs = [ pkgs.pkg-config pkgs.cmake From 8f5692eae944204dd36fac85070c7aa35f5809fb Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sun, 22 Nov 2026 09:22:22 -0600 Subject: [PATCH 2/9] pass shared Crane input to ID packages --- lib/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/default.nix b/lib/default.nix index d6d59dffe2..68bcf0c949 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -901,6 +901,7 @@ let # Root NixOS runtime output; the ID flake's named test # checks remain available and run through id-check CI. checkRuntimePackages = false; + crane = inputs.crane; } ); in From d1d343b200585ac239beba83f5d56d6b2814e5e2 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sun, 22 Nov 2026 23:50:14 -0600 Subject: [PATCH 3/9] fix(id): keep Biome available in full CI check --- pkgs/id/flake.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/id/flake.nix b/pkgs/id/flake.nix index 6539a3044b..83d74ea7d0 100644 --- a/pkgs/id/flake.nix +++ b/pkgs/id/flake.nix @@ -516,7 +516,11 @@ checks = { # CI-safe checks (read-only): cargo-fmt-check web-fmt-check clippy-lint web-lint test-sandbox test-crate-integration test-web-unit test-web-typecheck roc-test roc-examples doc build release # NixOS VM integration tests (Linux only): nixos-serve nixos-e2e - default = mkCheck "ci" "ci"; + default = mkCheckWith { + name = "ci"; + justCmd = "ci"; + extraNativeBuildInputs = [ pkgs.biome ]; + }; # Individual checks cargo-fmt-check = mkCheckRustOnly "cargo-fmt-check" "cargo-fmt-check"; From 71cafb85debbfad2149f08e35d7d46eb727ab295 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sun, 22 Nov 2026 23:57:24 -0600 Subject: [PATCH 4/9] perf(id): avoid duplicate aggregate check runs --- pkgs/id/flake.nix | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/pkgs/id/flake.nix b/pkgs/id/flake.nix index 83d74ea7d0..3fff4a76cd 100644 --- a/pkgs/id/flake.nix +++ b/pkgs/id/flake.nix @@ -513,14 +513,15 @@ # Checks: nix flake check -L # Uses 'ci' command (read-only, no auto-fix modifications) # ======================================================================= - checks = { + checks = + let + individualChecks = + { # CI-safe checks (read-only): cargo-fmt-check web-fmt-check clippy-lint web-lint test-sandbox test-crate-integration test-web-unit test-web-typecheck roc-test roc-examples doc build release # NixOS VM integration tests (Linux only): nixos-serve nixos-e2e - default = mkCheckWith { - name = "ci"; - justCmd = "ci"; - extraNativeBuildInputs = [ pkgs.biome ]; - }; + # Nix flake check builds all named checks as well as default. + # Use a link farm so the aggregate depends on those same results + # instead of rerunning the full CI recipe in a second derivation. # Individual checks cargo-fmt-check = mkCheckRustOnly "cargo-fmt-check" "cargo-fmt-check"; @@ -989,10 +990,10 @@ echo "prettier-check passed at $(date)" > $out/result.txt ''; }; - } - // ( - # NixOS VM integration tests (Linux only — VMs require KVM) - pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { + } + // ( + # NixOS VM integration tests (Linux only — VMs require KVM) + pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { nixos-serve = pkgs.testers.runNixOSTest ( import ./nix/tests/serve-test.nix { idPackage = self.packages.${system}.id-web; } ); @@ -1012,8 +1013,18 @@ inherit integrationTestRunner; } ); - } - ); + } + ); + in + individualChecks + // { + default = pkgs.linkFarm "id-checks" ( + pkgs.lib.mapAttrsToList (name: drv: { + inherit name; + path = drv; + }) individualChecks + ); + }; # ======================================================================= # Packages: nix build From 003d6abada109b0226188a507b4c9716c9c11cd6 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Sun, 22 Nov 2026 23:58:46 -0600 Subject: [PATCH 5/9] style(id): format aggregate check expression --- pkgs/id/flake.nix | 958 +++++++++++++++++++++++----------------------- 1 file changed, 479 insertions(+), 479 deletions(-) diff --git a/pkgs/id/flake.nix b/pkgs/id/flake.nix index 3fff4a76cd..91684493a7 100644 --- a/pkgs/id/flake.nix +++ b/pkgs/id/flake.nix @@ -517,502 +517,502 @@ let individualChecks = { - # CI-safe checks (read-only): cargo-fmt-check web-fmt-check clippy-lint web-lint test-sandbox test-crate-integration test-web-unit test-web-typecheck roc-test roc-examples doc build release - # NixOS VM integration tests (Linux only): nixos-serve nixos-e2e - # Nix flake check builds all named checks as well as default. - # Use a link farm so the aggregate depends on those same results - # instead of rerunning the full CI recipe in a second derivation. - - # Individual checks - cargo-fmt-check = mkCheckRustOnly "cargo-fmt-check" "cargo-fmt-check"; - web-fmt-check = mkCheckBiome "web-fmt-check" "web-fmt-check"; - clippy-lint = mkCheck "clippy-lint" "clippy-lint"; - # id-native-shell gate (#5582): the crate is a non-default - # workspace member, invisible to the default-member checks. - clippy-native-shell = mkCheckCargoOnly "clippy-native-shell" "clippy-native-shell"; - web-lint = mkCheckBiome "web-lint" "web-lint"; - test = mkCheck "test" "test-sandbox"; - test-unit = mkCheck "test-unit" "test-unit"; - test-crate-integration = mkCheck "test-crate-integration" "test-crate-integration"; - test-native-shell = mkCheckCargoOnly "test-native-shell" "test-native-shell"; - # Rust example guests (#7904): plaza-sdk (examples/rust-world) - # and rust-counter (examples/rust-counter) are standalone - # crates outside the pkgs/id workspace, so no workspace test - # check ever ran their unit tests (9 + 2). - test-rust-examples = mkCheckCargoOnly "test-rust-examples" "test-rust-examples"; - # Rebuild the Rust counter guest from source and run the - # sandbox tests against the rebuilt module (#7904) -- the - # roc-examples pattern. Wasm bytes are not reproducible - # across rustc builds or build paths (the producers/code - # sections differ between the rustup and rust-overlay - # builds of the same pinned 1.99.0), so a byte drift gate - # would be permanently red; what CI must prove is that the - # module built from current source passes the conformance - # tests that load it (src/sandbox.rs include_bytes!). - rust-counter-wasm = mkCheckWith { - name = "rust-counter-wasm"; - installWebDeps = false; - buildWebAssets = false; - beforeCheck = '' - export PATH="${rustToolchainWasm}/bin:$PATH" - bash examples/rust-counter/build.sh - ''; - checkCommand = '' - cargo test --no-default-features --features sandbox,world --lib sandbox - ''; - }; - test-int = mkCheck "test-int" "test-int-sandbox"; - # PR-gate shards of the integration suite (#869): the four - # shards together run every target test-sandbox runs, in - # parallel jobs instead of one serial ~25-minute check. - # (3 → 4 shards in #551: the 3-way shards had drifted to - # ~12.5 min, close to the fast-lane exit.) - # Keep the shard argument/empty-selection regression in the PR - # gate once, alongside shard 0, before running its real partition. - test-shard-0 = mkCheckWith { - name = "test-shard-0"; - checkCommand = '' - bash scripts/test-shard-sandbox-test.sh - just test-shard-sandbox 0 4 - ''; - }; - test-shard-1 = mkCheck "test-shard-1" "test-shard-sandbox 1 4"; - test-shard-2 = mkCheck "test-shard-2" "test-shard-sandbox 2 4"; - test-shard-3 = mkCheck "test-shard-3" "test-shard-sandbox 3 4"; - test-web = mkCheck "test-web" "test-web-sandbox"; - test-web-unit = mkCheckWebOnly "test-web-unit" "test-web-unit"; - test-web-typecheck = mkCheckWebOnly "test-web-typecheck" "test-web-typecheck"; - # Roc library expect() tests (#813): runs the roc-test just - # recipe with the pinned nightly from nix/roc.nix (already in - # nativeBuildInputs); fails on a missing compiler or a failing - # expect — the world_compile.rs skip path is not reused here. - roc-test = mkCheckWith { - name = "roc-test"; - needsCargoSetup = false; - needsRustToolchain = false; - needsBuildInputs = false; - installWebDeps = false; - buildWebAssets = false; - compileRocWorldHost = false; - extraNativeBuildInputs = [ rocCompiler ]; - justCmd = "roc-test"; - }; - # Rebuild all checked-in Roc examples with the pinned compiler, then - # run the sandbox behavior and fuel-budget tests against them. - roc-examples = mkCheckWith { - name = "roc-examples"; - installWebDeps = false; - buildWebAssets = false; - checkCommand = '' - cargo test --no-default-features --features sandbox,world --lib sandbox - cargo test --test toolchain_pin - ''; - extraNativeBuildInputs = [ - pkgs.binaryen - pkgs.wasm-tools - ]; - beforeCheck = '' - ROC=${rocCompiler}/bin/roc \ - WASM_TOOLS=${pkgs.wasm-tools}/bin/wasm-tools \ - WASM_OPT=${pkgs.binaryen}/bin/wasm-opt \ - bash scripts/rebuild-roc-examples.sh - ''; - }; - doc = mkCheckCargoOnly "doc" "doc"; - cargo-check = mkCheck "cargo-check" "cargo-check"; - # Production module-size guard (#1411): fails when any - # production .rs file exceeds 2,500 production lines. - # src/web/markdown.rs was the last id grandfather entry; its - # split into web/markdown/ submodules landed under #4704 and - # the entry was removed there, completing #1438. - prod-lines-check = mkCheckLean "prod-lines-check" "prod-lines-check"; - crash-gate = mkCheck "crash-gate" "crash-gate"; - # PR-gate splits of crash-gate (#551): the aggregate above runs - # every heavy full sweep serially (~15 min, the slowest PR - # check). These four checks partition the same tests by name - # filter and run in parallel on PRs; crash-gate itself stays - # for local use and the nightly full flake check, and is - # excluded from the PR list in check-id-pr-checks.sh. - crash-gate-sampled = mkCheck "crash-gate-sampled" "crash-gate-sampled"; - crash-gate-sweep = mkCheck "crash-gate-sweep" "crash-gate-sweep"; - crash-gate-control = mkCheck "crash-gate-control" "crash-gate-control"; - crash-gate-ingest = mkCheck "crash-gate-ingest" "crash-gate-ingest"; - # Drift guard for the generated just-recipes.json (#2729): fails - # when the checked-in JSON disagrees with the justfile on the - # semantic recipe fields. The recipe projects out generation - # noise (absolute source path, body serialisation), so this is - # green on any correctly regenerated file. - just-recipes-drift = mkCheckLean "just-recipes-drift" "just-recipes-check && bash scripts/just-recipes-check-test.sh"; - - # Planted-bug mutation proof (#8037, plan #1395): the script - # plants one named mutation at a time and requires the - # voiding/frontier suites to FAIL on each, after a green - # unmutated baseline. It drives git (rev-parse / apply / - # checkout) against repo-root-relative paths, and a flake - # check's src is pkgs/id alone with no .git, so the check - # stages a throwaway repo whose pkgs/id is this source tree, - # commits it, and runs the script there; the cargo vendor - # config the setup hook put in CARGO_HOME carries over, so - # the staged suites build offline like every other check. - # Nightly-only (full flake check): it runs the judged suites - # five times over, so it is excluded from the fast PR list - # in check-id-pr-checks.sh. - planted-bug-check = mkCheckWith { - name = "planted-bug-check"; - extraNativeBuildInputs = [ pkgs.git ]; - checkCommand = '' - stage=$(mktemp -d) - mkdir -p "$stage/pkgs/id" - tar --exclude=./target --exclude=./web/node_modules --exclude=./web/dist -cf - . | tar -xf - -C "$stage/pkgs/id" - git -C "$stage" init -q - git -C "$stage" add -A - git -C "$stage" -c user.email=ci@example.invalid -c user.name=ci commit -qm "stage pkgs/id for planted-bug-check" - bash "$stage/pkgs/id/tests/planted-bug-check.sh" - ''; - }; - - # Regression pins for scripts/build.sh variant handling (#6869): - # the fixture suite stubs cargo and exercises every variant, so a - # variant-specific regression fails here instead of in a just recipe. - build-sh-test = mkCheckWith { - name = "build-sh-test"; - needsRustToolchain = false; - needsCargoSetup = false; - needsBuildInputs = false; - installWebDeps = false; - buildWebAssets = false; - compileRocWorldHost = false; - checkCommand = "bash scripts/build-sh-test.sh"; - }; - - # Exercise the same alias-admission function used by apps against - # synthetic recipes/aliases, including dangling targets and names - # that would shadow recipe or manual apps. - just-recipes-alias-admission = - let - fixtureRecipes = { - public = { }; - private = { - private = true; - }; - default = { }; - recipeCollision = { }; - privateCollision = { - private = true; - }; - }; - fixtureAliases = { - valid = { - target = "public"; - }; - privateTarget = { - target = "private"; - }; - defaultTarget = { - target = "default"; - }; - missingTarget = { - target = "missing"; + # CI-safe checks (read-only): cargo-fmt-check web-fmt-check clippy-lint web-lint test-sandbox test-crate-integration test-web-unit test-web-typecheck roc-test roc-examples doc build release + # NixOS VM integration tests (Linux only): nixos-serve nixos-e2e + # Nix flake check builds all named checks as well as default. + # Use a link farm so the aggregate depends on those same results + # instead of rerunning the full CI recipe in a second derivation. + + # Individual checks + cargo-fmt-check = mkCheckRustOnly "cargo-fmt-check" "cargo-fmt-check"; + web-fmt-check = mkCheckBiome "web-fmt-check" "web-fmt-check"; + clippy-lint = mkCheck "clippy-lint" "clippy-lint"; + # id-native-shell gate (#5582): the crate is a non-default + # workspace member, invisible to the default-member checks. + clippy-native-shell = mkCheckCargoOnly "clippy-native-shell" "clippy-native-shell"; + web-lint = mkCheckBiome "web-lint" "web-lint"; + test = mkCheck "test" "test-sandbox"; + test-unit = mkCheck "test-unit" "test-unit"; + test-crate-integration = mkCheck "test-crate-integration" "test-crate-integration"; + test-native-shell = mkCheckCargoOnly "test-native-shell" "test-native-shell"; + # Rust example guests (#7904): plaza-sdk (examples/rust-world) + # and rust-counter (examples/rust-counter) are standalone + # crates outside the pkgs/id workspace, so no workspace test + # check ever ran their unit tests (9 + 2). + test-rust-examples = mkCheckCargoOnly "test-rust-examples" "test-rust-examples"; + # Rebuild the Rust counter guest from source and run the + # sandbox tests against the rebuilt module (#7904) -- the + # roc-examples pattern. Wasm bytes are not reproducible + # across rustc builds or build paths (the producers/code + # sections differ between the rustup and rust-overlay + # builds of the same pinned 1.99.0), so a byte drift gate + # would be permanently red; what CI must prove is that the + # module built from current source passes the conformance + # tests that load it (src/sandbox.rs include_bytes!). + rust-counter-wasm = mkCheckWith { + name = "rust-counter-wasm"; + installWebDeps = false; + buildWebAssets = false; + beforeCheck = '' + export PATH="${rustToolchainWasm}/bin:$PATH" + bash examples/rust-counter/build.sh + ''; + checkCommand = '' + cargo test --no-default-features --features sandbox,world --lib sandbox + ''; }; - recipeCollision = { - target = "public"; + test-int = mkCheck "test-int" "test-int-sandbox"; + # PR-gate shards of the integration suite (#869): the four + # shards together run every target test-sandbox runs, in + # parallel jobs instead of one serial ~25-minute check. + # (3 → 4 shards in #551: the 3-way shards had drifted to + # ~12.5 min, close to the fast-lane exit.) + # Keep the shard argument/empty-selection regression in the PR + # gate once, alongside shard 0, before running its real partition. + test-shard-0 = mkCheckWith { + name = "test-shard-0"; + checkCommand = '' + bash scripts/test-shard-sandbox-test.sh + just test-shard-sandbox 0 4 + ''; }; - privateCollision = { - target = "public"; + test-shard-1 = mkCheck "test-shard-1" "test-shard-sandbox 1 4"; + test-shard-2 = mkCheck "test-shard-2" "test-shard-sandbox 2 4"; + test-shard-3 = mkCheck "test-shard-3" "test-shard-sandbox 3 4"; + test-web = mkCheck "test-web" "test-web-sandbox"; + test-web-unit = mkCheckWebOnly "test-web-unit" "test-web-unit"; + test-web-typecheck = mkCheckWebOnly "test-web-typecheck" "test-web-typecheck"; + # Roc library expect() tests (#813): runs the roc-test just + # recipe with the pinned nightly from nix/roc.nix (already in + # nativeBuildInputs); fails on a missing compiler or a failing + # expect — the world_compile.rs skip path is not reused here. + roc-test = mkCheckWith { + name = "roc-test"; + needsCargoSetup = false; + needsRustToolchain = false; + needsBuildInputs = false; + installWebDeps = false; + buildWebAssets = false; + compileRocWorldHost = false; + extraNativeBuildInputs = [ rocCompiler ]; + justCmd = "roc-test"; }; - default = { - target = "public"; + # Rebuild all checked-in Roc examples with the pinned compiler, then + # run the sandbox behavior and fuel-budget tests against them. + roc-examples = mkCheckWith { + name = "roc-examples"; + installWebDeps = false; + buildWebAssets = false; + checkCommand = '' + cargo test --no-default-features --features sandbox,world --lib sandbox + cargo test --test toolchain_pin + ''; + extraNativeBuildInputs = [ + pkgs.binaryen + pkgs.wasm-tools + ]; + beforeCheck = '' + ROC=${rocCompiler}/bin/roc \ + WASM_TOOLS=${pkgs.wasm-tools}/bin/wasm-tools \ + WASM_OPT=${pkgs.binaryen}/bin/wasm-opt \ + bash scripts/rebuild-roc-examples.sh + ''; }; - just = { - target = "public"; + doc = mkCheckCargoOnly "doc" "doc"; + cargo-check = mkCheck "cargo-check" "cargo-check"; + # Production module-size guard (#1411): fails when any + # production .rs file exceeds 2,500 production lines. + # src/web/markdown.rs was the last id grandfather entry; its + # split into web/markdown/ submodules landed under #4704 and + # the entry was removed there, completing #1438. + prod-lines-check = mkCheckLean "prod-lines-check" "prod-lines-check"; + crash-gate = mkCheck "crash-gate" "crash-gate"; + # PR-gate splits of crash-gate (#551): the aggregate above runs + # every heavy full sweep serially (~15 min, the slowest PR + # check). These four checks partition the same tests by name + # filter and run in parallel on PRs; crash-gate itself stays + # for local use and the nightly full flake check, and is + # excluded from the PR list in check-id-pr-checks.sh. + crash-gate-sampled = mkCheck "crash-gate-sampled" "crash-gate-sampled"; + crash-gate-sweep = mkCheck "crash-gate-sweep" "crash-gate-sweep"; + crash-gate-control = mkCheck "crash-gate-control" "crash-gate-control"; + crash-gate-ingest = mkCheck "crash-gate-ingest" "crash-gate-ingest"; + # Drift guard for the generated just-recipes.json (#2729): fails + # when the checked-in JSON disagrees with the justfile on the + # semantic recipe fields. The recipe projects out generation + # noise (absolute source path, body serialisation), so this is + # green on any correctly regenerated file. + just-recipes-drift = mkCheckLean "just-recipes-drift" "just-recipes-check && bash scripts/just-recipes-check-test.sh"; + + # Planted-bug mutation proof (#8037, plan #1395): the script + # plants one named mutation at a time and requires the + # voiding/frontier suites to FAIL on each, after a green + # unmutated baseline. It drives git (rev-parse / apply / + # checkout) against repo-root-relative paths, and a flake + # check's src is pkgs/id alone with no .git, so the check + # stages a throwaway repo whose pkgs/id is this source tree, + # commits it, and runs the script there; the cargo vendor + # config the setup hook put in CARGO_HOME carries over, so + # the staged suites build offline like every other check. + # Nightly-only (full flake check): it runs the judged suites + # five times over, so it is excluded from the fast PR list + # in check-id-pr-checks.sh. + planted-bug-check = mkCheckWith { + name = "planted-bug-check"; + extraNativeBuildInputs = [ pkgs.git ]; + checkCommand = '' + stage=$(mktemp -d) + mkdir -p "$stage/pkgs/id" + tar --exclude=./target --exclude=./web/node_modules --exclude=./web/dist -cf - . | tar -xf - -C "$stage/pkgs/id" + git -C "$stage" init -q + git -C "$stage" add -A + git -C "$stage" -c user.email=ci@example.invalid -c user.name=ci commit -qm "stage pkgs/id for planted-bug-check" + bash "$stage/pkgs/id/tests/planted-bug-check.sh" + ''; }; - }; - admittedAliases = filterAliasApps fixtureRecipes fixtureAliases [ - "default" - "just" - ]; - fixtureRecipeApps = filterPublicRecipes fixtureRecipes; - fixtureApps = - (builtins.mapAttrs (_: _: "recipe") fixtureRecipeApps) - // (builtins.mapAttrs (_: _: "alias") admittedAliases) - // { - default = "manual"; - just = "manual"; + + # Regression pins for scripts/build.sh variant handling (#6869): + # the fixture suite stubs cargo and exercises every variant, so a + # variant-specific regression fails here instead of in a just recipe. + build-sh-test = mkCheckWith { + name = "build-sh-test"; + needsRustToolchain = false; + needsCargoSetup = false; + needsBuildInputs = false; + installWebDeps = false; + buildWebAssets = false; + compileRocWorldHost = false; + checkCommand = "bash scripts/build-sh-test.sh"; }; - in - assert builtins.attrNames admittedAliases == [ "valid" ]; - assert fixtureApps.recipeCollision == "recipe"; - assert fixtureApps.default == "manual"; - assert fixtureApps.just == "manual"; - pkgs.runCommand "id-just-recipes-alias-admission" { } '' - touch "$out" - ''; - # Playwright E2E tests (requires building the binary + browser binaries) - test-e2e = pkgs.stdenv.mkDerivation { - name = "id-test-e2e"; - src = ./.; - inherit buildInputs; - nativeBuildInputs = [ - rustToolchain - pkgs.pkg-config - pkgs.cmake - pkgs.bun - bun2nixPkg.hook - pkgs.rustPlatform.cargoSetupHook - # TODO: Switch back to `bunx playwright test` once Bun supports Playwright's - # ESM config loader (.esm.preflight virtual imports). Bun's runtime doesn't handle - # the Node.js-specific ESM hooks that Playwright uses for TypeScript config loading. - # Tracking: https://github.com/oven-sh/bun/pull/28610 - pkgs.nodejs - ]; - inherit cargoDeps; - inherit (opensslEnv) OPENSSL_DIR; - inherit (opensslEnv) OPENSSL_LIB_DIR; - inherit (opensslEnv) OPENSSL_INCLUDE_DIR; - inherit (opensslEnv) PKG_CONFIG_PATH; + # Exercise the same alias-admission function used by apps against + # synthetic recipes/aliases, including dangling targets and names + # that would shadow recipe or manual apps. + just-recipes-alias-admission = + let + fixtureRecipes = { + public = { }; + private = { + private = true; + }; + default = { }; + recipeCollision = { }; + privateCollision = { + private = true; + }; + }; + fixtureAliases = { + valid = { + target = "public"; + }; + privateTarget = { + target = "private"; + }; + defaultTarget = { + target = "default"; + }; + missingTarget = { + target = "missing"; + }; + recipeCollision = { + target = "public"; + }; + privateCollision = { + target = "public"; + }; + default = { + target = "public"; + }; + just = { + target = "public"; + }; + }; + admittedAliases = filterAliasApps fixtureRecipes fixtureAliases [ + "default" + "just" + ]; + fixtureRecipeApps = filterPublicRecipes fixtureRecipes; + fixtureApps = + (builtins.mapAttrs (_: _: "recipe") fixtureRecipeApps) + // (builtins.mapAttrs (_: _: "alias") admittedAliases) + // { + default = "manual"; + just = "manual"; + }; + in + assert builtins.attrNames admittedAliases == [ "valid" ]; + assert fixtureApps.recipeCollision == "recipe"; + assert fixtureApps.default == "manual"; + assert fixtureApps.just == "manual"; + pkgs.runCommand "id-just-recipes-alias-admission" { } '' + touch "$out" + ''; - # bun2nix hook: install web deps offline via pre-fetched cache - inherit bunDeps; - bunRoot = "web"; - bunInstallFlags = [ "--linker=hoisted" ]; - dontUseBunBuild = true; - dontUseBunCheck = true; - dontUseBunInstall = true; - dontUseCmakeConfigure = true; + # Playwright E2E tests (requires building the binary + browser binaries) + test-e2e = pkgs.stdenv.mkDerivation { + name = "id-test-e2e"; + src = ./.; + inherit buildInputs; + nativeBuildInputs = [ + rustToolchain + pkgs.pkg-config + pkgs.cmake + pkgs.bun + bun2nixPkg.hook + pkgs.rustPlatform.cargoSetupHook + # TODO: Switch back to `bunx playwright test` once Bun supports Playwright's + # ESM config loader (.esm.preflight virtual imports). Bun's runtime doesn't handle + # the Node.js-specific ESM hooks that Playwright uses for TypeScript config loading. + # Tracking: https://github.com/oven-sh/bun/pull/28610 + pkgs.nodejs + ]; + inherit cargoDeps; + inherit (opensslEnv) OPENSSL_DIR; + inherit (opensslEnv) OPENSSL_LIB_DIR; + inherit (opensslEnv) OPENSSL_INCLUDE_DIR; + inherit (opensslEnv) PKG_CONFIG_PATH; + + # bun2nix hook: install web deps offline via pre-fetched cache + inherit bunDeps; + bunRoot = "web"; + bunInstallFlags = [ "--linker=hoisted" ]; + dontUseBunBuild = true; + dontUseBunCheck = true; + dontUseBunInstall = true; + dontUseCmakeConfigure = true; - buildPhase = '' - export HOME=$(mktemp -d) - export CARGO_HOME=$HOME/.cargo + buildPhase = '' + export HOME=$(mktemp -d) + export CARGO_HOME=$HOME/.cargo - # @tailwindcss/cli uses @parcel/watcher (native module) which needs libstdc++ - export LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" + # @tailwindcss/cli uses @parcel/watcher (native module) which needs libstdc++ + export LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" - # Build web assets (bun2nix hook already installed node_modules via bunNodeModulesInstallPhase) - (cd web && bun run build) - - # Build the binary with web feature - cargo build --features web - - # Install e2e deps from pre-fetched cache (separate from web deps) - E2E_CACHE_DIR=$(mktemp -d) - cp -r "${e2eBunDeps}"/share/bun-cache/. "$E2E_CACHE_DIR" - (cd e2e && BUN_INSTALL_CACHE_DIR="$E2E_CACHE_DIR" \ - bun install --frozen-lockfile --linker=hoisted) - - # Configure Playwright to use nix-provided browsers - export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 - export PLAYWRIGHT_BROWSERS_PATH="${pkgs.playwright-driver.browsers}" - - # Unset LD_LIBRARY_PATH before running Playwright — nix-patched Chromium - # has its own RPATH and the extra libstdc++ path (needed for @parcel/watcher - # during web build above) can interfere with Chromium's library resolution, - # causing it to hang on launch in the nix sandbox. - unset LD_LIBRARY_PATH - - # Run Playwright E2E tests — one invocation per spec file (#229). - # playwright.config.ts starts ONE ephemeral server per browser - # project for the whole invocation, so a single full-suite run - # lets every spec observe the files/state earlier specs created - # on that shared server (the Firefox shared-state failure - # cluster: e.g. basic.spec's "empty state" test ran after - # autosave.spec had already created files). A fresh invocation - # per spec file gives each file a fresh ephemeral server. - # All files run even if one fails, so one run reports every - # failing file; the check fails if any file failed. - # TODO: Switch to `bunx playwright test` once Bun's ESM loader supports - # Playwright's .esm.preflight virtual imports for TypeScript config loading. - # Tracking: https://github.com/oven-sh/bun/pull/28610 - ( - cd e2e - e2e_status=0 - for spec in tests/*.spec.ts; do - echo "=== test-e2e isolated per-spec run: $spec ===" - node node_modules/@playwright/test/cli.js test "$spec" || e2e_status=1 - done - exit $e2e_status - ) - ''; - installPhase = '' - mkdir -p $out - echo "test-e2e passed at $(date)" > $out/result.txt - ''; - }; + # Build web assets (bun2nix hook already installed node_modules via bunNodeModulesInstallPhase) + (cd web && bun run build) + + # Build the binary with web feature + cargo build --features web + + # Install e2e deps from pre-fetched cache (separate from web deps) + E2E_CACHE_DIR=$(mktemp -d) + cp -r "${e2eBunDeps}"/share/bun-cache/. "$E2E_CACHE_DIR" + (cd e2e && BUN_INSTALL_CACHE_DIR="$E2E_CACHE_DIR" \ + bun install --frozen-lockfile --linker=hoisted) + + # Configure Playwright to use nix-provided browsers + export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 + export PLAYWRIGHT_BROWSERS_PATH="${pkgs.playwright-driver.browsers}" + + # Unset LD_LIBRARY_PATH before running Playwright — nix-patched Chromium + # has its own RPATH and the extra libstdc++ path (needed for @parcel/watcher + # during web build above) can interfere with Chromium's library resolution, + # causing it to hang on launch in the nix sandbox. + unset LD_LIBRARY_PATH + + # Run Playwright E2E tests — one invocation per spec file (#229). + # playwright.config.ts starts ONE ephemeral server per browser + # project for the whole invocation, so a single full-suite run + # lets every spec observe the files/state earlier specs created + # on that shared server (the Firefox shared-state failure + # cluster: e.g. basic.spec's "empty state" test ran after + # autosave.spec had already created files). A fresh invocation + # per spec file gives each file a fresh ephemeral server. + # All files run even if one fails, so one run reports every + # failing file; the check fails if any file failed. + # TODO: Switch to `bunx playwright test` once Bun's ESM loader supports + # Playwright's .esm.preflight virtual imports for TypeScript config loading. + # Tracking: https://github.com/oven-sh/bun/pull/28610 + ( + cd e2e + e2e_status=0 + for spec in tests/*.spec.ts; do + echo "=== test-e2e isolated per-spec run: $spec ===" + node node_modules/@playwright/test/cli.js test "$spec" || e2e_status=1 + done + exit $e2e_status + ) + ''; + installPhase = '' + mkdir -p $out + echo "test-e2e passed at $(date)" > $out/result.txt + ''; + }; - nix-fmt-check = pkgs.stdenv.mkDerivation { - name = "id-nix-fmt-check"; - src = ./.; - nativeBuildInputs = [ pkgs.nixfmt ]; - buildPhase = '' - find . -name '*.nix' -not -path './web/bun.nix' -not -path './e2e/bun.nix' | xargs nixfmt --check - ''; - installPhase = '' - mkdir -p $out - echo "nix-fmt-check passed at $(date)" > $out/result.txt - ''; - }; - treefmt-check = pkgs.stdenv.mkDerivation { - name = "id-treefmt-check"; - src = ./.; - nativeBuildInputs = fmtBins; - buildPhase = '' - treefmt --config-file ./treefmt.toml --tree-root "$(pwd)" --ci 2>&1 - ''; - installPhase = '' - mkdir -p $out - echo "treefmt-check passed at $(date)" > $out/result.txt - ''; - }; + nix-fmt-check = pkgs.stdenv.mkDerivation { + name = "id-nix-fmt-check"; + src = ./.; + nativeBuildInputs = [ pkgs.nixfmt ]; + buildPhase = '' + find . -name '*.nix' -not -path './web/bun.nix' -not -path './e2e/bun.nix' | xargs nixfmt --check + ''; + installPhase = '' + mkdir -p $out + echo "nix-fmt-check passed at $(date)" > $out/result.txt + ''; + }; + treefmt-check = pkgs.stdenv.mkDerivation { + name = "id-treefmt-check"; + src = ./.; + nativeBuildInputs = fmtBins; + buildPhase = '' + treefmt --config-file ./treefmt.toml --tree-root "$(pwd)" --ci 2>&1 + ''; + installPhase = '' + mkdir -p $out + echo "treefmt-check passed at $(date)" > $out/result.txt + ''; + }; - # Per-formatter checks (read-only validation) - biome-check = pkgs.stdenv.mkDerivation { - name = "id-biome-check"; - src = ./.; - nativeBuildInputs = [ pkgs.biome ]; - buildPhase = '' - biome format \ - --files-ignore-unknown=true \ - $(find . \( -name '*.js' -o -name '*.jsx' -o -name '*.ts' -o -name '*.tsx' \ - -o -name '*.css' -o -name '*.json' -o -name '*.graphql' \) \ - -not -path '*/node_modules/*' -not -path '*/target/*' \ - -not -path '*/dist/*') - ''; - installPhase = '' - mkdir -p $out - echo "biome-check passed at $(date)" > $out/result.txt - ''; - }; - rustfmt-check = pkgs.stdenv.mkDerivation { - name = "id-rustfmt-check"; - src = ./.; - nativeBuildInputs = [ rustToolchain ]; - buildPhase = '' - find . -name '*.rs' -not -path '*/target/*' \ - -exec rustfmt --check --edition 2024 {} + - ''; - installPhase = '' - mkdir -p $out - echo "rustfmt-check passed at $(date)" > $out/result.txt - ''; - }; - statix-check = pkgs.stdenv.mkDerivation { - name = "id-statix-check"; - src = ./.; - nativeBuildInputs = [ pkgs.statix ]; - buildPhase = '' - # Collect failures across files instead of swallowing each - # one: a pipe into `while` would run the loop in a subshell - # and lose the flag, so feed it via process substitution. - fail=0 - while IFS= read -r -d "" f; do - statix check -- "$f" || fail=1 - done < <(find . -name '*.nix' -print0) - if [ "$fail" -ne 0 ]; then - echo "statix-check: statix reported problems above" >&2 - false - fi - ''; - installPhase = '' - mkdir -p $out - echo "statix-check passed at $(date)" > $out/result.txt - ''; - }; - shfmt-check = pkgs.stdenv.mkDerivation { - name = "id-shfmt-check"; - src = ./.; - nativeBuildInputs = [ pkgs.shfmt ]; - buildPhase = '' - find . -name '*.sh' -not -path '*/node_modules/*' \ - -exec shfmt -d -i 2 -s {} + - ''; - installPhase = '' - mkdir -p $out - echo "shfmt-check passed at $(date)" > $out/result.txt - ''; - }; - shellcheck-check = pkgs.stdenv.mkDerivation { - name = "id-shellcheck-check"; - src = ./.; - nativeBuildInputs = [ pkgs.shellcheck ]; - buildPhase = '' - # Enforced at warning severity (#702): under sandbox - # conditions shellcheck reports only four info findings - # (SC2012, `ls` glob picks in the examples' build.sh - # files) and no warning-or-above findings, so warnings - # and errors fail the gate while those info findings - # are worked down separately. - find . -name '*.sh' -not -path '*/node_modules/*' \ - -exec shellcheck --severity=warning {} + - ''; - installPhase = '' - mkdir -p $out - echo "shellcheck-check passed at $(date)" > $out/result.txt - ''; - }; - taplo-check = pkgs.stdenv.mkDerivation { - name = "id-taplo-check"; - src = ./.; - nativeBuildInputs = [ pkgs.taplo ]; - buildPhase = '' - find . -name '*.toml' -not -path '*/target/*' \ - -exec taplo check {} + - ''; - installPhase = '' - mkdir -p $out - echo "taplo-check passed at $(date)" > $out/result.txt - ''; - }; - justfmt-check = pkgs.stdenv.mkDerivation { - name = "id-justfmt-check"; - src = ./.; - nativeBuildInputs = [ pkgs.just ]; - buildPhase = '' - just --fmt --check --justfile ./justfile - ''; - installPhase = '' - mkdir -p $out - echo "justfmt-check passed at $(date)" > $out/result.txt - ''; - }; - prettier-check = pkgs.stdenv.mkDerivation { - name = "id-prettier-check"; - src = ./.; - nativeBuildInputs = [ pkgs.prettier ]; # nodepackages remove 2026-04-03 - buildPhase = '' - find . \( -name '*.html' -o -name '*.md' -o -name '*.mdx' \ - -o -name '*.scss' -o -name '*.yaml' \) \ - -not -path '*/node_modules/*' -not -path '*/target/*' \ - -not -path '*/dist/*' \ - -exec prettier --check {} + - ''; - installPhase = '' - mkdir -p $out - echo "prettier-check passed at $(date)" > $out/result.txt - ''; - }; + # Per-formatter checks (read-only validation) + biome-check = pkgs.stdenv.mkDerivation { + name = "id-biome-check"; + src = ./.; + nativeBuildInputs = [ pkgs.biome ]; + buildPhase = '' + biome format \ + --files-ignore-unknown=true \ + $(find . \( -name '*.js' -o -name '*.jsx' -o -name '*.ts' -o -name '*.tsx' \ + -o -name '*.css' -o -name '*.json' -o -name '*.graphql' \) \ + -not -path '*/node_modules/*' -not -path '*/target/*' \ + -not -path '*/dist/*') + ''; + installPhase = '' + mkdir -p $out + echo "biome-check passed at $(date)" > $out/result.txt + ''; + }; + rustfmt-check = pkgs.stdenv.mkDerivation { + name = "id-rustfmt-check"; + src = ./.; + nativeBuildInputs = [ rustToolchain ]; + buildPhase = '' + find . -name '*.rs' -not -path '*/target/*' \ + -exec rustfmt --check --edition 2024 {} + + ''; + installPhase = '' + mkdir -p $out + echo "rustfmt-check passed at $(date)" > $out/result.txt + ''; + }; + statix-check = pkgs.stdenv.mkDerivation { + name = "id-statix-check"; + src = ./.; + nativeBuildInputs = [ pkgs.statix ]; + buildPhase = '' + # Collect failures across files instead of swallowing each + # one: a pipe into `while` would run the loop in a subshell + # and lose the flag, so feed it via process substitution. + fail=0 + while IFS= read -r -d "" f; do + statix check -- "$f" || fail=1 + done < <(find . -name '*.nix' -print0) + if [ "$fail" -ne 0 ]; then + echo "statix-check: statix reported problems above" >&2 + false + fi + ''; + installPhase = '' + mkdir -p $out + echo "statix-check passed at $(date)" > $out/result.txt + ''; + }; + shfmt-check = pkgs.stdenv.mkDerivation { + name = "id-shfmt-check"; + src = ./.; + nativeBuildInputs = [ pkgs.shfmt ]; + buildPhase = '' + find . -name '*.sh' -not -path '*/node_modules/*' \ + -exec shfmt -d -i 2 -s {} + + ''; + installPhase = '' + mkdir -p $out + echo "shfmt-check passed at $(date)" > $out/result.txt + ''; + }; + shellcheck-check = pkgs.stdenv.mkDerivation { + name = "id-shellcheck-check"; + src = ./.; + nativeBuildInputs = [ pkgs.shellcheck ]; + buildPhase = '' + # Enforced at warning severity (#702): under sandbox + # conditions shellcheck reports only four info findings + # (SC2012, `ls` glob picks in the examples' build.sh + # files) and no warning-or-above findings, so warnings + # and errors fail the gate while those info findings + # are worked down separately. + find . -name '*.sh' -not -path '*/node_modules/*' \ + -exec shellcheck --severity=warning {} + + ''; + installPhase = '' + mkdir -p $out + echo "shellcheck-check passed at $(date)" > $out/result.txt + ''; + }; + taplo-check = pkgs.stdenv.mkDerivation { + name = "id-taplo-check"; + src = ./.; + nativeBuildInputs = [ pkgs.taplo ]; + buildPhase = '' + find . -name '*.toml' -not -path '*/target/*' \ + -exec taplo check {} + + ''; + installPhase = '' + mkdir -p $out + echo "taplo-check passed at $(date)" > $out/result.txt + ''; + }; + justfmt-check = pkgs.stdenv.mkDerivation { + name = "id-justfmt-check"; + src = ./.; + nativeBuildInputs = [ pkgs.just ]; + buildPhase = '' + just --fmt --check --justfile ./justfile + ''; + installPhase = '' + mkdir -p $out + echo "justfmt-check passed at $(date)" > $out/result.txt + ''; + }; + prettier-check = pkgs.stdenv.mkDerivation { + name = "id-prettier-check"; + src = ./.; + nativeBuildInputs = [ pkgs.prettier ]; # nodepackages remove 2026-04-03 + buildPhase = '' + find . \( -name '*.html' -o -name '*.md' -o -name '*.mdx' \ + -o -name '*.scss' -o -name '*.yaml' \) \ + -not -path '*/node_modules/*' -not -path '*/target/*' \ + -not -path '*/dist/*' \ + -exec prettier --check {} + + ''; + installPhase = '' + mkdir -p $out + echo "prettier-check passed at $(date)" > $out/result.txt + ''; + }; } // ( # NixOS VM integration tests (Linux only — VMs require KVM) pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { - nixos-serve = pkgs.testers.runNixOSTest ( - import ./nix/tests/serve-test.nix { idPackage = self.packages.${system}.id-web; } - ); - nixos-e2e = pkgs.testers.runNixOSTest ( - import ./nix/tests/e2e-test.nix { idPackage = self.packages.${system}.id-web; } - ); - nixos-playwright-e2e = pkgs.testers.runNixOSTest ( - import ./nix/tests/playwright-e2e-test.nix { - idPackage = self.packages.${system}.id-web; - inherit e2eTestRunner; - playwrightBrowsers = pkgs.playwright-driver.browsers; - } - ); - nixos-integration = pkgs.testers.runNixOSTest ( - import ./nix/tests/integration-test.nix { - idPackage = self.packages.${system}.id-web; - inherit integrationTestRunner; - } - ); + nixos-serve = pkgs.testers.runNixOSTest ( + import ./nix/tests/serve-test.nix { idPackage = self.packages.${system}.id-web; } + ); + nixos-e2e = pkgs.testers.runNixOSTest ( + import ./nix/tests/e2e-test.nix { idPackage = self.packages.${system}.id-web; } + ); + nixos-playwright-e2e = pkgs.testers.runNixOSTest ( + import ./nix/tests/playwright-e2e-test.nix { + idPackage = self.packages.${system}.id-web; + inherit e2eTestRunner; + playwrightBrowsers = pkgs.playwright-driver.browsers; + } + ); + nixos-integration = pkgs.testers.runNixOSTest ( + import ./nix/tests/integration-test.nix { + idPackage = self.packages.${system}.id-web; + inherit integrationTestRunner; + } + ); } ); in From 39085164cd1e7ce7d788913b0c73839c4b002647 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 23 Nov 2026 00:00:43 -0600 Subject: [PATCH 6/9] fix(id): preserve default CI check scope --- pkgs/id/flake.nix | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/pkgs/id/flake.nix b/pkgs/id/flake.nix index 91684493a7..6f6dabb444 100644 --- a/pkgs/id/flake.nix +++ b/pkgs/id/flake.nix @@ -1018,11 +1018,27 @@ in individualChecks // { - default = pkgs.linkFarm "id-checks" ( - pkgs.lib.mapAttrsToList (name: drv: { + default = pkgs.linkFarm "id-ci" ( + map (name: { inherit name; - path = drv; - }) individualChecks + path = individualChecks.${name}; + }) [ + "cargo-fmt-check" + "web-fmt-check" + "cargo-check" + "clippy-lint" + "clippy-native-shell" + "web-lint" + "test" + "test-native-shell" + "test-rust-examples" + "test-web-unit" + "test-web-typecheck" + "roc-test" + "doc" + "build" + "release" + ] ); }; From e146d6c056fd3b20b63bdaf0d481c201c25e037a Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 23 Nov 2026 00:02:56 -0600 Subject: [PATCH 7/9] fix(id): preserve aggregate build checks --- pkgs/id/flake.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/id/flake.nix b/pkgs/id/flake.nix index 6f6dabb444..a88106906d 100644 --- a/pkgs/id/flake.nix +++ b/pkgs/id/flake.nix @@ -619,6 +619,8 @@ ''; }; doc = mkCheckCargoOnly "doc" "doc"; + build = mkCheck "build" "build"; + release = mkCheck "release" "release"; cargo-check = mkCheck "cargo-check" "cargo-check"; # Production module-size guard (#1411): fails when any # production .rs file exceeds 2,500 production lines. From 350fe5bf9f17a1a5f287cb5da3d53b810d1f3857 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 23 Nov 2026 00:07:41 -0600 Subject: [PATCH 8/9] perf(id): reuse named test shards in aggregate checks --- pkgs/id/flake.nix | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/pkgs/id/flake.nix b/pkgs/id/flake.nix index a88106906d..2282f2def3 100644 --- a/pkgs/id/flake.nix +++ b/pkgs/id/flake.nix @@ -515,6 +515,14 @@ # ======================================================================= checks = let + mkCheckAggregate = + name: members: + pkgs.linkFarm name ( + map (member: { + name = member; + path = individualChecks.${member}; + }) members + ); individualChecks = { # CI-safe checks (read-only): cargo-fmt-check web-fmt-check clippy-lint web-lint test-sandbox test-crate-integration test-web-unit test-web-typecheck roc-test roc-examples doc build release @@ -531,7 +539,15 @@ # workspace member, invisible to the default-member checks. clippy-native-shell = mkCheckCargoOnly "clippy-native-shell" "clippy-native-shell"; web-lint = mkCheckBiome "web-lint" "web-lint"; - test = mkCheck "test" "test-sandbox"; + # test-unit plus the four shards cover the same root suite + # as test-sandbox, without building and running that suite twice. + test = mkCheckAggregate "id-test" [ + "test-unit" + "test-shard-0" + "test-shard-1" + "test-shard-2" + "test-shard-3" + ]; test-unit = mkCheck "test-unit" "test-unit"; test-crate-integration = mkCheck "test-crate-integration" "test-crate-integration"; test-native-shell = mkCheckCargoOnly "test-native-shell" "test-native-shell"; @@ -561,7 +577,14 @@ cargo test --no-default-features --features sandbox,world --lib sandbox ''; }; - test-int = mkCheck "test-int" "test-int-sandbox"; + # The shards cover the integration target as well as + # the unit/bin/doc tests assigned to shard zero. + test-int = mkCheckAggregate "id-test-int" [ + "test-shard-0" + "test-shard-1" + "test-shard-2" + "test-shard-3" + ]; # PR-gate shards of the integration suite (#869): the four # shards together run every target test-sandbox runs, in # parallel jobs instead of one serial ~25-minute check. @@ -579,7 +602,13 @@ test-shard-1 = mkCheck "test-shard-1" "test-shard-sandbox 1 4"; test-shard-2 = mkCheck "test-shard-2" "test-shard-sandbox 2 4"; test-shard-3 = mkCheck "test-shard-3" "test-shard-sandbox 3 4"; - test-web = mkCheck "test-web" "test-web-sandbox"; + # Compose the Rust and web checks already run separately + # by nix flake check instead of rebuilding them in one derivation. + test-web = mkCheckAggregate "id-test-web" [ + "test" + "test-web-unit" + "test-web-typecheck" + ]; test-web-unit = mkCheckWebOnly "test-web-unit" "test-web-unit"; test-web-typecheck = mkCheckWebOnly "test-web-typecheck" "test-web-typecheck"; # Roc library expect() tests (#813): runs the roc-test just From 234db532152ad31d67dd17b2276b7ac832c0e691 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 23 Nov 2026 00:10:14 -0600 Subject: [PATCH 9/9] perf(id): keep aggregate-only build checks scoped --- pkgs/id/flake.nix | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkgs/id/flake.nix b/pkgs/id/flake.nix index 2282f2def3..3f9af23e60 100644 --- a/pkgs/id/flake.nix +++ b/pkgs/id/flake.nix @@ -523,6 +523,10 @@ path = individualChecks.${member}; }) members ); + ciBuildChecks = { + build = mkCheck "build" "build"; + release = mkCheck "release" "release"; + }; individualChecks = { # CI-safe checks (read-only): cargo-fmt-check web-fmt-check clippy-lint web-lint test-sandbox test-crate-integration test-web-unit test-web-typecheck roc-test roc-examples doc build release @@ -648,8 +652,6 @@ ''; }; doc = mkCheckCargoOnly "doc" "doc"; - build = mkCheck "build" "build"; - release = mkCheck "release" "release"; cargo-check = mkCheck "cargo-check" "cargo-check"; # Production module-size guard (#1411): fails when any # production .rs file exceeds 2,500 production lines. @@ -1046,13 +1048,14 @@ ); } ); + ciChecks = individualChecks // ciBuildChecks; in individualChecks // { default = pkgs.linkFarm "id-ci" ( map (name: { inherit name; - path = individualChecks.${name}; + path = ciChecks.${name}; }) [ "cargo-fmt-check" "web-fmt-check"