Something went wrong. Try again.
atproto Thingiverse but good
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768#!/usr/bin/env bashset -euo pipefailif (($# == 0)); then echo "usage: tools/in-dev-shell [--print-dev-env | _private-recipe [args ...]]" >&2 exit 2fiprint_dev_env=0if [[ $1 == --print-dev-env ]]; then print_dev_env=1 shiftelif [[ $1 != _* ]]; then echo "error: expected --print-dev-env or a private Just recipe" >&2 exit 2fiprivate_recipe=${1:-}if ((print_dev_env == 0)); then shiftfiif ((print_dev_env == 0)); then if ! just_bin=$(command -v just); then echo "error: just is required to dispatch Polymodel recipes" >&2 exit 127 fi if [[ "${POLYMODEL_NIX_SHELL:-}" == 1 && -n "${LDRAWDIR:-}" && -d "${LDRAWDIR}" ]]; then exec "$just_bin" "$private_recipe" "$@" fifiif ! nix_bin=$(command -v nix); then echo "error: nix is required to enter the Polymodel dev shell" >&2 exit 127fiscript_path=${BASH_SOURCE[0]}[[ $script_path == */* ]] || script_path=./$script_pathroot=$(cd "${script_path%/*}/.." && pwd)flake_ref=$rootif [[ -e "$root/.jj" && ! -e "$root/.git" ]]; then if ! jj_bin=$(command -v jj); then echo "error: jj is required to materialize a secondary-workspace flake" >&2 exit 127 fi snapshot=$($jj_bin --repository "$root" log -r @ --no-graph -T 'commit_id') cache_root=${XDG_CACHE_HOME:-${HOME}/.cache}/polymodel/jj-flakes flake_ref=$cache_root/$snapshot if [[ ! -f "$flake_ref/flake.nix" ]]; then mkdir -p "$cache_root" staging=$(mktemp -d "$cache_root/.staging.XXXXXX") trap 'rm -rf "$staging"' EXIT "$jj_bin" --repository "$root" file list -r @ -T 'path ++ "\0"' \ | tar -C "$root" --null --verbatim-files-from -T - -cf - \ | tar -xf - -C "$staging" mv "$staging" "$flake_ref" 2>/dev/null || true fifiif ((print_dev_env)); then exec "$nix_bin" print-dev-env "$flake_ref"fiprintf '==> entering Polymodel dev shell for: %s\n' "${private_recipe#_}" >&2exec "$nix_bin" develop "$flake_ref" --command "$just_bin" "$private_recipe" "$@"