Files
faumarayandClaude Opus 5.5 c9859bcfb4 spikes/gpui: the GPUI spikes' workspace, environment and meter
Plan section 6 step 1. A Cargo workspace of its own under spikes/gpui (own
lock, not a member of the root workspace, so the root's lock, deny policy,
notices and CI are untouched; it builds into the checkout's target/), on
gpui-kit pinned to =0.8.0. No gpui-kit release builds on Rust 1.94 (every
gpui-pre 0.3.x calls std::hint::cold_path, stable since 1.95), so the
workspace says rust-version 1.95.

- shell.sh: the toolchain (1.95.0, 1.94, stable or nightly, all from one
  pinned fenix), the native libraries, Mesa's lavapipe as the only Vulkan
  driver, Xvfb, openbox and the X tools, Noto Color Emoji and Noto Sans CJK.
- headless.sh: a private Xvfb display with openbox and a private session
  bus, never the desktop's; headless-wayland.sh: sway's headless backend.
- spike-common: CPU by thread group and memory from /proc once a second
  with the spike's counters (meter), proc-meter and damage-count for
  programs without a meter (the Slint app), Inter and the emoji/CJK fonts,
  the client's Lucide icons as GPUI assets, and the BGRA twin of
  voelin_media::convert::to_rgba.

From the interrupted 2026-10-25 attempt, kept; changed here: shell.sh takes
1.94 and nightly from the pinned fenix (the store paths it named were
garbage-collected), the README's headless-wayland.sh paragraph (sway, not
weston), its fmt command (-p, not --all), its toolchain and nixpkgs lines,
and the font docs (GPUI drops Noto Color Emoji from a fallback chain).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 01:43:20 +03:00

75 lines
3.9 KiB
Bash
Executable File

#!/bin/sh
# Run a command with the spikes' build and run environment (NixOS): the
# native libraries GPUI and voelin-media link, Mesa (lavapipe, the software
# Vulkan device), the Vulkan loader, Xvfb, a window manager and the X tools
# the measurements use, and a Rust toolchain on PATH.
#
# spikes/gpui/shell.sh cargo build --locked --release
# TOOLCHAIN=nightly spikes/gpui/shell.sh cargo build --locked
#
# TOOLCHAIN: 1.95 (default: the oldest release gpui-kit builds with), 1.94
# (rust-toolchain.toml's, which cannot build gpui-kit), stable or nightly,
# all from one pinned fenix (stable: 2026-10-15's, nightly: 2026-10-24's);
# RUST_BIN overrides the directory with cargo and rustc. VK_DRIVER_FILES: the
# Vulkan drivers GPUI may use (default: lavapipe alone).
set -eu
substituters="https://cache.nixos.org/ https://nix-community.cachix.org"
fenix=github:nix-community/fenix/e691190ae78c9551d1e6a0cba156555c8f7cceca
components='[ "cargo" "rustc" "rust-std" "clippy" "rustfmt" ]'
case "${TOOLCHAIN:-1.95}" in
1.95) toolchain="(f.toolchainOf { channel = \"1.95.0\"; sha256 = \"sha256-gh/xTkxKHL4eiRXzWv8KP7vfjSk61Iq48x47BEDFgfk=\"; })" ;;
1.94) toolchain="(f.toolchainOf { channel = \"1.94.0\"; sha256 = \"sha256-qqF33vNuAdU5vua96VKVIwuc43j4EFeEXbjQ6+l4mO4=\"; })" ;;
stable) toolchain=f.stable ;;
nightly) toolchain=f.latest ;;
*) echo "shell.sh: TOOLCHAIN is 1.95, 1.94, stable or nightly" >&2; exit 2 ;;
esac
if [ -z "${RUST_BIN:-}" ]; then
default_bin=$(nix build --option substituters "$substituters" --no-link --print-out-paths --impure \
--expr "let f = (builtins.getFlake \"$fenix\").packages.x86_64-linux; in $toolchain.withComponents $components")/bin
fi
RUST_BIN=${RUST_BIN:-$default_bin}
# Tools (bin/ on PATH) and libraries (lib/ and pkg-config files).
tools="gcc cmake gnumake pkg-config jq xvfb xdotool xwd imagemagick vulkan-tools
procps xclip coreutils openbox dbus xrandr xdpyinfo xprop xwininfo"
# Libraries with every output (lib/ and the pkg-config files are in different
# ones).
libs="alsa-lib openssl libvpx dav1d pipewire fontconfig freetype libxkbcommon
expat wayland libxcb vulkan-loader libglvnd libx11 libxcursor libxrandr libxi libxext
libxrender"
installables="nixpkgs#libclang.lib nixpkgs#glibc.dev nixpkgs#mesa nixpkgs#noto-fonts-color-emoji
nixpkgs#noto-fonts-cjk-sans"
for p in $tools; do installables="$installables nixpkgs#$p"; done
for p in $libs; do installables="$installables nixpkgs#$p^*"; done
# shellcheck disable=SC2086
paths=$(nix build --option substituters "$substituters" --no-link --print-out-paths $installables)
bin= pc= lib=
for p in $paths; do
[ -d "$p/bin" ] && bin="$bin:$p/bin"
[ -d "$p/lib/pkgconfig" ] && pc="$pc:$p/lib/pkgconfig"
[ -d "$p/share/pkgconfig" ] && pc="$pc:$p/share/pkgconfig"
[ -d "$p/lib" ] && lib="$lib:$p/lib"
case $p in
*-mesa-[0-9]*) [ -e "$p/share/vulkan/icd.d/lvp_icd.x86_64.json" ] && MESA=$p ;;
*-clang-*-lib) [ -e "$p/lib/libclang.so" ] && LIBCLANG_PATH=$p/lib ;;
*-glibc-*-dev) GLIBC_INCLUDE=$p/include ;;
*-noto-fonts-color-emoji-*) SPIKE_EMOJI_FONT=$p/share/fonts/noto/NotoColorEmoji.ttf ;;
*-noto-fonts-cjk-sans-*) SPIKE_EXTRA_FONTS=$p/share/fonts/opentype/noto-cjk/NotoSansCJK-VF.otf.ttc ;;
esac
done
export PATH="$RUST_BIN$bin:$PATH"
export PKG_CONFIG_PATH="${pc#:}"
# Run time: the Vulkan loader, libGL/EGL, Wayland and xkbcommon are opened
# by name (dlopen); link time: -L for every library above.
export LD_LIBRARY_PATH="${lib#:}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export LIBRARY_PATH="${lib#:}"
export LIBCLANG_PATH MESA
# The fonts the spikes add to GPUI (common/src/fonts.rs): colour emoji, CJK.
export SPIKE_EMOJI_FONT SPIKE_EXTRA_FONTS
# bindgen (libclang, unwrapped) needs the C library's headers.
export BINDGEN_EXTRA_CLANG_ARGS="-isystem $GLIBC_INCLUDE"
export VK_DRIVER_FILES="${VK_DRIVER_FILES:-$MESA/share/vulkan/icd.d/lvp_icd.x86_64.json}"
export __EGL_VENDOR_LIBRARY_DIRS="$MESA/share/glvnd/egl_vendor.d"
exec "$@"