nandi/frqpublic Fork 0
a400a009193bf22dc2f2e46cc06d2d12eeaaf107
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.

bb · 50 lines · 2.1 KBBash Blame HistoryRaw
Take bb from the flake, so a checkout needs nix and nothing else 270bee0 nandi 16d ago1#!/bin/sh
2# babashka, which the scripts here are written in.
3#
4# A build script wants the things a shell is bad at — reading deps.edn, hashing
5# a file set, holding a path in a variable without quoting it three times — and
6# Clojure is already the language this repo is written in.
7#
8# This used to be a DotSlash manifest, pinning a release of babashka the way
9# the native libraries are pinned. It is the flake's now, for the reason the
10# flake exists: a bb from `nixpkgs` is one this tree already names a version
11# of, so a checkout needs nix and nothing else. DotSlash still answers for the
12# desktop libraries — those are jolt-native's releases, which no nixpkgs has —
13# but nothing has to be installed to reach *them* any more either, because the
14# script that fetches them starts here.
15#
16# Three answers, in order:
17#
18# bb on PATH the dev shell puts one there, and so does a machine that
19# has its own; either is what the caller meant
20# the flake built once and kept alive by the symlink under build/,
21# which is a gc root as well as a cache
22# the container nix is not on every host this runs on — see CLAUDE.md —
23# so a host without one re-enters this script where nix is,
24# which is where the scripts want to be anyway
25set -e
Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago26
Take bb from the flake, so a checkout needs nix and nothing else 270bee0 nandi 16d ago27root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
28
29if command -v bb >/dev/null 2>&1; then
30 exec bb "$@"
31fi
32
33link="$root/build/bb"
34
35if command -v nix >/dev/null 2>&1; then
36 # --out-link rather than --no-link: the path has to survive a gc, and the
37 # symlink is what roots it. Rebuilt only when it is gone or dangling, so
38 # the usual case is one readlink.
39 [ -x "$link/bin/bb" ] || nix build "$root#bb" --out-link "$link" >&2
40 exec "$link/bin/bb" "$@"
41fi
42
43if [ -n "$FRQ_BB_REENTERED" ]; then
44 echo "scripts/bb: no bb and no nix, inside the container too." >&2
45 echo "Install babashka, or put a nix on this machine." >&2
46 exit 1
47fi
48
49exec distrobox enter arch -- bash -lc \
50 "cd $root && FRQ_BB_REENTERED=1 exec scripts/bb \"\$@\"" -- "$@"