Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

fix(nix): inject NixOS PATH on container smoke docker exec

Test754b4dbc6a10
diff --git a/scripts/test-nixos-systemd-container.sh b/scripts/test-nixos-systemd-container.sh
index 989a12d5..f8f03535 100755
--- a/scripts/test-nixos-systemd-container.sh
+++ b/scripts/test-nixos-systemd-container.sh
@@ -34,11 +34,10 @@ MARKER_VALUE="nixos-container-smoke"
ENGINE=""
ROOTFS=""
BUILT_IMAGE=0
-# docker import leaves no image ENV PATH. nixpkgs documents absolute NixOS
-# paths for docker exec (see virtualisation/docker-image.nix). Prefer the
-# profile path — present in the rootfs before activation links
-# /run/current-system.
-NIXOS_SW_BIN="/nix/var/nix/profiles/system/sw/bin"
+# docker import leaves no image ENV PATH. Inject the NixOS system bin dirs
+# on every exec (nixpkgs docker-image.nix documents /run/current-system/…).
+# Profile path covers the brief window before activation links current-system.
+NIXOS_PATH="/run/current-system/sw/bin:/nix/var/nix/profiles/system/sw/bin:/bin"
log() {
printf '\n==> %s\n' "$*"
@@ -50,19 +49,11 @@ fail() {
}
ctr_exec() {
- "${ENGINE}" exec "${CONTAINER_NAME}" "$@"
+ "${ENGINE}" exec -e "PATH=${NIXOS_PATH}" "${CONTAINER_NAME}" "$@"
}
-ctr_systemctl() {
- ctr_exec "${NIXOS_SW_BIN}/systemctl" "$@"
-}
-
-ctr_journalctl() {
- ctr_exec "${NIXOS_SW_BIN}/journalctl" "$@"
-}
-
-ctr_curl() {
- ctr_exec "${NIXOS_SW_BIN}/curl" "$@"
+ctr_exec_root() {
+ "${ENGINE}" exec -u root -e "PATH=${NIXOS_PATH}" "${CONTAINER_NAME}" "$@"
}
repo_root() {
@@ -107,25 +98,25 @@ wait_for_http() {
local url="$1"
local i
for i in $(seq 1 120); do
- if ctr_curl -fsS "${url}" >/dev/null 2>&1; then
+ if ctr_exec curl -fsS "${url}" >/dev/null 2>&1; then
return 0
fi
sleep 0.5
done
- ctr_journalctl -u ai-memory --no-pager -n 120 >&2 || true
+ ctr_exec journalctl -u ai-memory --no-pager -n 120 >&2 || true
fail "timed out waiting for in-container ${url}"
}
wait_for_active() {
local i
for i in $(seq 1 120); do
- if ctr_systemctl is-active --quiet ai-memory; then
+ if ctr_exec systemctl is-active --quiet ai-memory; then
return 0
fi
sleep 0.5
done
- ctr_systemctl status ai-memory --no-pager >&2 || true
- ctr_journalctl -u ai-memory --no-pager -n 120 >&2 || true
+ ctr_exec systemctl status ai-memory --no-pager >&2 || true
+ ctr_exec journalctl -u ai-memory --no-pager -n 120 >&2 || true
fail "timed out waiting for systemctl is-active ai-memory"
}
@@ -143,15 +134,14 @@ run_container() {
}
write_marker() {
- # /bin/sh is the activation-created wrapper; present once systemd has
- # finished early boot (we only write markers after wait_for_active).
- "${ENGINE}" exec -u root "${CONTAINER_NAME}" /bin/sh -c \
+ # PATH is injected so chown/coreutils resolve after activation.
+ ctr_exec_root /bin/sh -c \
"printf '%s\n' '${MARKER_VALUE}' > '${MARKER_PATH}' && chown ai-memory:ai-memory '${MARKER_PATH}'"
}
assert_marker() {
local got
- got="$(ctr_exec "${NIXOS_SW_BIN}/cat" "${MARKER_PATH}")"
+ got="$(ctr_exec cat "${MARKER_PATH}")"
if [ "${got}" != "${MARKER_VALUE}" ]; then
fail "marker mismatch at ${MARKER_PATH}: expected '${MARKER_VALUE}', got '${got}'"
fi
@@ -160,15 +150,15 @@ assert_marker() {
smoke_once() {
log "Waiting for ai-memory unit"
wait_for_active
- ctr_systemctl is-active ai-memory
+ ctr_exec systemctl is-active ai-memory
log "Waiting for in-container ${HEALTH_URL}"
wait_for_http "${HEALTH_URL}"
- ctr_curl -fsS "${HEALTH_URL}" >/dev/null
+ ctr_exec curl -fsS "${HEALTH_URL}" >/dev/null
log "Writing marker and restarting ai-memory"
write_marker
- ctr_systemctl restart ai-memory
+ ctr_exec systemctl restart ai-memory
wait_for_active
wait_for_http "${HEALTH_URL}"
assert_marker