diff --git a/nix/zed-package.nix b/nix/zed-package.nix index e8d628fb..c8591594 100644 --- a/nix/zed-package.nix +++ b/nix/zed-package.nix @@ -179,6 +179,20 @@ rec { exit 1 fi + # `.zed/operation.lock` is durable mutable-checkout coordination state. + # It carries operation/process diagnostics and must never enter a + # recursive fixed output. Deterministic adapter-owned state such as + # `.zed/node_path` remains in the materialized package tree. + operation_lock="$work/.zed/operation.lock" + if [[ -e "$operation_lock" ]]; then + if [[ -L "$operation_lock" || ! -f "$operation_lock" ]]; then + echo "zed-pkg Nix bridge: operation lock is not a regular file" >&2 + exit 1 + fi + rm -f "$operation_lock" + rmdir "$work/.zed" 2>/dev/null || true + fi + mkdir -p "$out/tree" "$out/metadata" shopt -s dotglob nullglob for entry in "$work"/*; do @@ -314,6 +328,8 @@ rec { fi done < <(find "$out/tree" -type l -print0) + test ! -e "$out/tree/.zed/operation.lock" + runHook postInstall ''; }; diff --git a/tests/frozen-lock-integrity-e2e.sh b/tests/frozen-lock-integrity-e2e.sh index fe4daf41..a1f252d7 100644 --- a/tests/frozen-lock-integrity-e2e.sh +++ b/tests/frozen-lock-integrity-e2e.sh @@ -184,7 +184,20 @@ assert_atomic_failure() { || fail "$label rewrote its rejected lock" [[ ! -e "$root/zed_modules" ]] || fail "$label materialized zed_modules" [[ ! -e "$root/node_modules" ]] || fail "$label materialized node_modules" - [[ ! -e "$root/.zed" ]] || fail "$label materialized native adapter state" + if [[ -e "$root/.zed" ]]; then + [[ -d "$root/.zed" && ! -L "$root/.zed" ]] \ + || fail "$label created unsafe .zed state" + unexpected_state="$( + find "$root/.zed" -mindepth 1 \ + ! -path "$root/.zed/operation.lock" -print -quit + )" + [[ -z "$unexpected_state" ]] \ + || fail "$label materialized native adapter state: $unexpected_state" + if [[ -e "$root/.zed/operation.lock" ]]; then + [[ -f "$root/.zed/operation.lock" && ! -L "$root/.zed/operation.lock" ]] \ + || fail "$label left an unsafe operation lock" + fi + fi if [[ -d "$root/.zpkg-staging" ]]; then [[ -z "$(find "$root/.zpkg-staging" -mindepth 1 -print -quit)" ]] \ || fail "$label left transaction state" diff --git a/tests/nix/interop.nix b/tests/nix/interop.nix index 7dcc948d..98707a33 100644 --- a/tests/nix/interop.nix +++ b/tests/nix/interop.nix @@ -72,6 +72,7 @@ let test -f .vendor/.zed/zed-pkg/docker-node-lib/package.json test -f node_modules/@zed-pkg/docker-node-lib/package.json test ! -e .vendor/.zed/zed-pkg/docker-node-lib/generated/output.txt + test ! -e .zed/operation.lock runHook postCheck '';