nandi/frqpublic Fork 0
1e8b590d18da31fbf5670dd346964bb09599a1da
Commits
Clone
git clone https://git.rickub.com/nandi/frq.git
git clone ssh://git@rickub.com/nandi/frq.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Take bb from the flake, so a checkout needs nix and nothing else 270bee0 · on 1e8b590d18da31fbf5670dd346964bb09599a1da · nandi · 16d ago
bb · 50 lines · 2.1 KBBash Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
# babashka, which the scripts here are written in.
#
# A build script wants the things a shell is bad at — reading deps.edn, hashing
# a file set, holding a path in a variable without quoting it three times — and
# Clojure is already the language this repo is written in.
#
# This used to be a DotSlash manifest, pinning a release of babashka the way
# the native libraries are pinned. It is the flake's now, for the reason the
# flake exists: a bb from `nixpkgs` is one this tree already names a version
# of, so a checkout needs nix and nothing else. DotSlash still answers for the
# desktop libraries — those are jolt-native's releases, which no nixpkgs has —
# but nothing has to be installed to reach *them* any more either, because the
# script that fetches them starts here.
#
# Three answers, in order:
#
#   bb on PATH      the dev shell puts one there, and so does a machine that
#                   has its own; either is what the caller meant
#   the flake       built once and kept alive by the symlink under build/,
#                   which is a gc root as well as a cache
#   the container   nix is not on every host this runs on — see CLAUDE.md —
#                   so a host without one re-enters this script where nix is,
#                   which is where the scripts want to be anyway
set -e

root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)

if command -v bb >/dev/null 2>&1; then
    exec bb "$@"
fi

link="$root/build/bb"

if command -v nix >/dev/null 2>&1; then
    # --out-link rather than --no-link: the path has to survive a gc, and the
    # symlink is what roots it. Rebuilt only when it is gone or dangling, so
    # the usual case is one readlink.
    [ -x "$link/bin/bb" ] || nix build "$root#bb" --out-link "$link" >&2
    exec "$link/bin/bb" "$@"
fi

if [ -n "$FRQ_BB_REENTERED" ]; then
    echo "scripts/bb: no bb and no nix, inside the container too." >&2
    echo "Install babashka, or put a nix on this machine." >&2
    exit 1
fi

exec distrobox enter arch -- bash -lc \
    "cd $root && FRQ_BB_REENTERED=1 exec scripts/bb \"\$@\"" -- "$@"