nandi/frqpublic Fork 0
25a3f7bd954c4c6d060d7edb6a4b951ebbf81adb
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 · 58 lines · 2.6 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
Ask the bb on PATH who it is before handing it a script 57c6de2 nandi 16d ago19# has its own; either is what the caller meant — as long as
20# it is babashka. `bb` is also what bazel's own launcher
21# calls itself, and a host with one of those ahead of the
22# shell's answered every recipe here with "Command
23# 'scripts/tui.bb' not found. Try 'bb help'", which reads as
24# a missing script rather than the wrong program
Take bb from the flake, so a checkout needs nix and nothing else 270bee0 nandi 16d ago25# the flake built once and kept alive by the symlink under build/,
26# which is a gc root as well as a cache
27# the container nix is not on every host this runs on — see CLAUDE.md —
28# so a host without one re-enters this script where nix is,
29# which is where the scripts want to be anyway
30set -e
Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago31
Take bb from the flake, so a checkout needs nix and nothing else 270bee0 nandi 16d ago32root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
33
Ask the bb on PATH who it is before handing it a script 57c6de2 nandi 16d ago34# Asking it who it is, rather than trusting the name: the version line is the
35# cheapest question babashka answers and the one nothing else answers the same
36# way.
37if command -v bb >/dev/null 2>&1 && bb --version 2>/dev/null | grep -qi '^babashka'; then
Take bb from the flake, so a checkout needs nix and nothing else 270bee0 nandi 16d ago38 exec bb "$@"
39fi
40
41link="$root/build/bb"
42
43if command -v nix >/dev/null 2>&1; then
44 # --out-link rather than --no-link: the path has to survive a gc, and the
45 # symlink is what roots it. Rebuilt only when it is gone or dangling, so
46 # the usual case is one readlink.
47 [ -x "$link/bin/bb" ] || nix build "$root#bb" --out-link "$link" >&2
48 exec "$link/bin/bb" "$@"
49fi
50
51if [ -n "$FRQ_BB_REENTERED" ]; then
52 echo "scripts/bb: no bb and no nix, inside the container too." >&2
53 echo "Install babashka, or put a nix on this machine." >&2
54 exit 1
55fi
56
57exec distrobox enter arch -- bash -lc \
58 "cd $root && FRQ_BB_REENTERED=1 exec scripts/bb \"\$@\"" -- "$@"