Monorepo for Tangled tangled.org
2

Configure Feed

Select the types of activity you want to include in your feed.

nix/microvm: use closureInfo not derivation inputs in user-config

Signed-off-by: dawn <dawn@tangled.org>

author
dawn
date (Jun 24, 2026, 5:08 PM +0300) commit 9b3e1670 parent 9ab13625 change-id vmrsrwok
+45 -9
+1 -1
nix/microvm/user-config.nix
··· 116 116 # we do this instead of using a `.nix` file because it lets us skip eval time. 117 117 environment.etc = lib.mkIf (dependencies != []) { 118 118 "spindle/devshell.drv".source = spindleDevShell.drvPath; 119 - "spindle/devshell-inputs".source = spindleDevShell.inputDerivation; 119 + "spindle/devshell-closure".source = pkgs.closureInfo {rootPaths = [spindleDevShell];}; 120 120 }; 121 121 services = builtins.mapAttrs (normalize (options.services or {})) (userConfig.services or {}); 122 122 virtualisation = builtins.mapAttrs (normalize (options.virtualisation or {})) (userConfig.virtualisation or {});
+44 -8
spindle/engines/microvm/test-spindle-microvm.sh
··· 1 1 #!/usr/bin/env bash 2 2 set -euo pipefail 3 + # dont export big captures like `out=$(run_vm ...)` into the environment. 4 + set +a 5 + # extglob enables the *(...) pattern strip_ansi uses for pure-bash CSI stripping 6 + shopt -s extglob 3 7 # note: needs `sudo modprobe vhost_vsock`! 4 8 5 9 log() { 6 10 printf "\n\033[1;36m>>> %s\033[0m\n" "$*" 11 + } 12 + 13 + _strip_ansi_stream() { 14 + local line 15 + while IFS= read -r line || [ -n "$line" ]; do 16 + line=${line//$'\e'\[*([0-9;])[a-zA-Z]/} 17 + line=${line//$'\e'\([a-zA-Z]/} 18 + printf '%s\n' "$line" 19 + done 7 20 } 8 21 9 22 strip_ansi() { 10 - local esc 11 - esc=$(printf '\033') 12 - sed -E "s/${esc}\[[0-9;]*[a-zA-Z]//g; s/${esc}\([a-zA-Z]//g" "$@" 23 + if [ "$#" -gt 0 ]; then 24 + local f 25 + for f in "$@"; do 26 + [ -r "$f" ] && _strip_ansi_stream < "$f" 27 + done 28 + else 29 + _strip_ansi_stream 30 + fi 13 31 } 14 32 15 33 # check_needles OUT NEEDLES... 34 + # each needle is an extended regex matched per line (mirrors `grep -qE`). 16 35 check_needles() { 17 36 local out="$1" 18 37 shift 19 - local clean 20 - clean=$(echo "$out" | strip_ansi) 38 + 39 + local -a lines 40 + mapfile -t lines <<< "$out" 21 41 22 - local needle missing=0 42 + # strip ANSI per line (each line is short, so this stays cheap) 43 + local i l 44 + for i in "${!lines[@]}"; do 45 + l=${lines[i]} 46 + l=${l//$'\e'\[*([0-9;])[a-zA-Z]/} 47 + l=${l//$'\e'\([a-zA-Z]/} 48 + lines[i]=$l 49 + done 50 + 51 + local needle missing=0 line hit 23 52 for needle in "$@"; do 24 - if ! echo "$clean" | grep -qE "$needle"; then 53 + hit=0 54 + for line in "${lines[@]}"; do 55 + if [[ $line =~ $needle ]]; then 56 + hit=1 57 + break 58 + fi 59 + done 60 + if [ "$hit" -eq 0 ]; then 25 61 echo "error: output missing '$needle'" >&2 26 62 missing=1 27 63 fi 28 64 done 29 65 30 66 if [ "$missing" -ne 0 ]; then 31 - echo "$clean" >&2 67 + printf '%s\n' "${lines[@]}" >&2 32 68 return 1 33 69 fi 34 70 }