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.
1234567891011121314151617181920212223242526272829303132333435363738#!/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/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"(cd "$root" && gleam build) >&2mkdir -p "$out"for ebin in "$root"/build/dev/erlang/*/ebin; do package="$(dirname "$ebin")" name="$(basename "$package")" mkdir -p "$out/$name" cp -R "$ebin" "$out/$name/ebin" # A priv that links to a source tree keeps pointing at it, as under # `gleam run`. One the build itself holds (a dependency's NIF) is copied: # a rebuild by another toolchain deletes it under a running daemon. if [ -L "$package/priv" ]; then ln -s "$(cd "$package/priv" && pwd -P)" "$out/$name/priv" elif [ -d "$package/priv" ]; then cp -R "$package/priv" "$out/$name/priv" fidonecat >"$out/albedo-daemon" <<EOF#!/bin/shexec "$root/priv/bin/albedo-daemon" erl -pa "$out"/*/ebin -eval 'albedo@@main:run(albedo)' -noshell -extra "\$@"EOFchmod +x "$out/albedo-daemon"echo "$out/albedo-daemon"