Files
komorebi/scripts/linux/vm-mac
T
LGUG2Z 1afac08af5 fix(scripts): the Linux scripts find the repository from scripts/linux/
The scripts were written for a KDE-only repository root (komorebi-for-kde/, scripts/ one
level below it). They now live in scripts/linux/ of the consolidated repository:
- run-kde looks for the repository two directories above itself (flake.nix at the root) and
  no longer knows the komorebi-for-kde/ subdirectory; its comments name nix/linux and docs/linux
- vm-mac cd`s two levels up, usage and comments name scripts/linux/vm-mac
- sync-e2e-core and scenario-status read nix/linux/tests/vm/lib, and usage lines name the new
  paths (scenario-status resolves the library with parents[2])
- wsl2-probe.sh names docs/linux/dev/wsl2-probe.md and prints "komorebi (KDE Plasma)" instead of
  komorebi-for-kde in its report header
- compare-gen.py is stale by design: the docstring now says so a second time (layout) and
  names the new path of COMPARE.md; the logic is not repaired

Flake attribute names the scripts call (nix run .#run-kde, .#wsl2-probe, legacyPackages.*.vm.NAME
in vm-mac) are left for the one-flake revision.

Verified: bash -n and shellcheck -S warning pass on the four shell scripts; the two Python
scripts parse (ast); `bash run-kde --dry-run` run from /tmp prints KOMOREBI_REPO as this
checkout; `sync-e2e-core --check e2e/lib` prints "in step"; `scenario-status --help` runs.
Not run: the VM, vm-mac, wsl2-probe.
2026-11-05 15:03:27 -08:00

48 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Runs one VM test on a Mac, where the guest is Linux and the host is not.
#
# scripts/linux/vm-mac NAME [driver arguments]
#
# The guest's closure is built on a Linux builder, copied back, and the test driver then runs
# on the Mac under HVF. The driver is run directly, not through `nix build`, because the nix
# sandbox on macOS cannot give QEMU the hypervisor. Artifacts (screenshots, logs) land in
# `.vm/out/NAME`.
#
# The builder is yours: set KOMOREBI_BUILDER to its store URL (for example
# `ssh-ng://builder@localhost`) and, if it needs them, NIX_SSHOPTS. docs/linux/dev/vm-tests.md
# says what a builder has to be.
set -euo pipefail
name="${1:?usage: scripts/linux/vm-mac NAME [driver arguments]}"
shift
builder="${KOMOREBI_BUILDER:?set KOMOREBI_BUILDER to the store URL of a Linux builder}"
cd "$(dirname "$0")/../.."
attr="legacyPackages.aarch64-darwin.vm.$name"
test="path:$PWD#$attr"
# a git checkout is a flake source without its untracked files (.vm, target); the repository may be
# a subdirectory of a bigger git repository, whose toplevel is not $PWD
if top=$(git rev-parse --show-toplevel 2> /dev/null); then
if [ "$top" = "$PWD" ]; then
test="git+file://$PWD#$attr"
else
test="git+file://$top?dir=${PWD#"$top"/}#$attr"
fi
fi
echo "== building the guests on $builder"
nix eval --json "$test.nodes" --apply 'nodes: builtins.mapAttrs (_: node: node.system.build.toplevel.drvPath) nodes' |
jq -r '.[]' |
while read -r drv; do
out=$(nix build "$drv^out" --eval-store auto --store "$builder" --no-link --print-out-paths)
nix copy --from "$builder" --substitute-on-destination --no-check-sigs "$out"
done
echo "== building the driver"
driver=$(nix build "$test.driver" --builders '' --no-link --print-out-paths)
out="$PWD/.vm/out/$name"
mkdir -p "$out"
echo "== running $name (artifacts in $out)"
cd "$out"
exec "$driver/bin/nixos-test-driver" -o . "$@"