Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253#!/usr/bin/env bash# Compile the daemon and copy its code into $1 beside a launcher, then print the# launcher's path for ALBEDO_DAEMON. Test daemons boot from the copy instead of# `gleam run`: none of them takes the build lock, so they boot side by side and# beside a running `gleam test`, and a rebuild during the run cannot change the# code under a daemon that is still loading modules.set -euo pipefailroot="$(cd "$(dirname "$0")/.." && pwd)"out="$1"# A git dependency fetch must not walk up into the checkout's shared .git (see# nix/devShells.nix).export GIT_CEILING_DIRECTORIES="$root/apps/albedo/build${GIT_CEILING_DIRECTORIES:+:$GIT_CEILING_DIRECTORIES}"# A reused directory would keep the previous beams, and `ln -s` would follow its# old priv link into the checkout.rm -rf "$out"# The checkout's build step also rebuilds albedo's application when it holds a# stale copy of a module that moved into a workspace package."$root/apps/albedo/priv/bin/albedo-build"mkdir -p "$out"for ebin in "$root"/apps/albedo/build/dev/erlang/*/ebin; do package="$(dirname "$ebin")" name="$(basename "$package")" mkdir -p "$out/$name" cp -R "$ebin" "$out/$name/ebin" # A sealed snapshot owns its priv tree too; later source edits cannot change it. if [ -d "$package/priv" ]; then mkdir -p "$out/$name/priv" tar -chf - --exclude='./python/.venv' --exclude='./python/package.nix' -C "$package/priv" . | tar -xf - -C "$out/$name/priv" fidone# The interpreter stays outside the sealed tree. Keep the build's selection# as the launcher default so it also works when started outside the dev shell.python="${ALBEDO_KERNEL_PYTHON:-}"if [[ -z $python && -x "$root/python/.venv/bin/python" ]]; then python="$root/python/.venv/bin/python"fiif [[ -n $python ]]; then printf '%s\n' "$python" >"$out/kernel-python"fi# Python caches are build artifacts, not changes to a sealed snapshot."${python:-python3}" -m compileall -q -f --invalidation-mode checked-hash "$out/albedo/priv/python"ALBEDO_BUILD_APP="$out/albedo" "$root/apps/albedo/priv/bin/albedo-daemon" erl -pa "$out"/*/ebin -noshell -eval 'application:ensure_all_started(crypto), {ok, nil} = albedo@lifecycle@build_identity:seal_build(unicode:characters_to_binary(os:getenv("ALBEDO_BUILD_APP"))), halt().'cat >"$out/albedo-daemon" <<EOF#!/bin/shif [ -z "\${ALBEDO_KERNEL_PYTHON:-}" ] && [ -f "$out/kernel-python" ]; then IFS= read -r ALBEDO_KERNEL_PYTHON <"$out/kernel-python" export ALBEDO_KERNEL_PYTHONfiexec "$root/apps/albedo/priv/bin/albedo-daemon" erl -pa "$out"/*/ebin -eval 'albedo@@main:run(albedo)' -noshell -extra "\$@"EOFchmod +x "$out/albedo-daemon"echo "$out/albedo-daemon"