Files
Pigeon/vm.nix
T

25 lines
624 B
Nix
Raw Normal View History

2026-10-14 23:44:34 -04:00
{
2026-10-15 01:40:00 -04:00
writeShellApplication,
coreutils, firecracker, jq,
pigeon-vmconfig
2026-10-14 23:44:34 -04:00
}:
2026-10-15 01:40:00 -04:00
writeShellApplication {
name = "pigeon-vm";
runtimeInputs = [ coreutils firecracker jq ];
text = ''
[ "$#" -ne 3 ] && exit 1
2026-10-14 23:44:34 -04:00
2026-10-15 01:40:00 -04:00
CONFIG="$(mktemp)"
trap 'rm -rf "$CONFIG"' EXIT
2026-10-14 23:44:34 -04:00
2026-10-15 01:40:00 -04:00
jq --arg s "$1" --arg g "$2" --arg r "$3" '
(.drives[] | select(.drive_id == "student").path_on_host) = $s |
(.drives[] | select(.drive_id == "grader").path_on_host) = $g |
(.drives[] | select(.drive_id == "results").path_on_host) = $r
' ${pigeon-vmconfig} >"$CONFIG"
2026-10-14 23:44:34 -04:00
2026-10-15 01:40:00 -04:00
firecracker --no-api --config-file "$CONFIG"
2026-10-14 23:44:34 -04:00
'';
2026-10-15 01:40:00 -04:00
}