Take bb from the flake, so a checkout needs nix and nothing else
scripts/bb was a DotSlash manifest, which meant every script in this tree needed a dotslash on PATH before it could run — including the one that starts the app, whose whole job is to get into a nix shell. A bb is something nixpkgs has and this tree already locks a version of, so it may as well come from the same place everything else does. Three answers, in order: a bb on PATH, which is what the dev shell now puts there; the flake's `.#bb`, built once and rooted by the symlink under build/, so the second call is a readlink rather than an eval; and, on a host with no nix at all, this script re-entered inside the container, which is where the scripts wanted to be anyway. DotSlash still pins the desktop libraries — those are jolt-native's releases and no nixpkgs has them — but nothing needs to be installed to reach them any more, because the script that fetches them starts here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
270bee0 parent: ac6c46a modified
README.md +5 -0 | @@ -41,6 +41,11 @@ just lib | ||
| 41 | 41 | just run |
| 42 | 42 | ``` |
| 43 | 43 | |
| 44 | +The scripts under `scripts/` are babashka, reached through `scripts/bb`: a bb | |
| 45 | +on `PATH` if there is one — the dev shell puts one there — and otherwise the | |
| 46 | +flake's `.#bb`, built once and kept under `build/`. Nothing has to be installed | |
| 47 | +for that but Nix. | |
| 48 | + | |
| 44 | 49 | `just lib` fetches both shared objects this client loads — |
| 45 | 50 | [jolt-native](https://gitlab.com/nandithebull/jolt-native)'s `libvidya`, the |
| 46 | 51 | retained-tree ABI glimmer paints through, and `libjoltmoq`, the AV media plane |
| @@ -41,6 +41,11 @@ just lib | |||
| 41 | just run | 41 | just run |
| 42 | ``` | 42 | ``` |
| 43 | 43 | ||
| 44 | +The scripts under `scripts/` are babashka, reached through `scripts/bb`: a bb | ||
| 45 | +on `PATH` if there is one — the dev shell puts one there — and otherwise the | ||
| 46 | +flake's `.#bb`, built once and kept under `build/`. Nothing has to be installed | ||
| 47 | +for that but Nix. | ||
| 48 | + | ||
| 44 | `just lib` fetches both shared objects this client loads — | 49 | `just lib` fetches both shared objects this client loads — |
| 45 | [jolt-native](https://gitlab.com/nandithebull/jolt-native)'s `libvidya`, the | 50 | [jolt-native](https://gitlab.com/nandithebull/jolt-native)'s `libvidya`, the |
| 46 | retained-tree ABI glimmer paints through, and `libjoltmoq`, the AV media plane | 51 | retained-tree ABI glimmer paints through, and `libjoltmoq`, the AV media plane |
modified
flake.nix +10 -2 | @@ -315,6 +315,12 @@ | ||
| 315 | 315 | jolt = joltRuntime; |
| 316 | 316 | default = frq; |
| 317 | 317 | |
| 318 | + # The interpreter scripts/ is written in, named here so that | |
| 319 | + # scripts/bb can build it. Nothing else in this flake uses it: it is | |
| 320 | + # an output because a shell script cannot ask for `nixpkgs#babashka` | |
| 321 | + # at the version this tree pins, and `.#bb` is exactly that. | |
| 322 | + bb = pkgs.babashka; | |
| 323 | + | |
| 318 | 324 | # frq and everything it loads, squashed into one runnable file for |
| 319 | 325 | # hosts without Nix. The whole closure rides along — Mesa included, |
| 320 | 326 | # which is not waste: off NixOS the launcher goes through nixGL, and |
| @@ -366,8 +372,10 @@ | ||
| 366 | 372 | |
| 367 | 373 | # jolt, because the runtime frq is run by should be the flake's |
| 368 | 374 | # too. nixGL for the same reason the launcher reaches for it — see |
| 369 | - # frqScript. | |
| 370 | - packages = [ jolt (nixGLFor pkgs) ]; | |
| 375 | + # frqScript. babashka because scripts/bb prefers one on PATH, and | |
| 376 | + # inside here that should be this one rather than a second copy | |
| 377 | + # built through `.#bb`. | |
| 378 | + packages = [ jolt pkgs.babashka (nixGLFor pkgs) ]; | |
| 371 | 379 | |
| 372 | 380 | # Read by scripts/run.bb rather than baked into a wrapper: the frq |
| 373 | 381 | # source `just run` runs is the working tree, so the launcher has |
| @@ -315,6 +315,12 @@ | |||
| 315 | jolt = joltRuntime; | 315 | jolt = joltRuntime; |
| 316 | default = frq; | 316 | default = frq; |
| 317 | 317 | ||
| 318 | + # The interpreter scripts/ is written in, named here so that | ||
| 319 | + # scripts/bb can build it. Nothing else in this flake uses it: it is | ||
| 320 | + # an output because a shell script cannot ask for `nixpkgs#babashka` | ||
| 321 | + # at the version this tree pins, and `.#bb` is exactly that. | ||
| 322 | + bb = pkgs.babashka; | ||
| 323 | + | ||
| 318 | # frq and everything it loads, squashed into one runnable file for | 324 | # frq and everything it loads, squashed into one runnable file for |
| 319 | # hosts without Nix. The whole closure rides along — Mesa included, | 325 | # hosts without Nix. The whole closure rides along — Mesa included, |
| 320 | # which is not waste: off NixOS the launcher goes through nixGL, and | 326 | # which is not waste: off NixOS the launcher goes through nixGL, and |
| @@ -366,8 +372,10 @@ | |||
| 366 | 372 | ||
| 367 | # jolt, because the runtime frq is run by should be the flake's | 373 | # jolt, because the runtime frq is run by should be the flake's |
| 368 | # too. nixGL for the same reason the launcher reaches for it — see | 374 | # too. nixGL for the same reason the launcher reaches for it — see |
| 369 | - # frqScript. | 375 | + # frqScript. babashka because scripts/bb prefers one on PATH, and |
| 370 | - packages = [ jolt (nixGLFor pkgs) ]; | 376 | + # inside here that should be this one rather than a second copy |
| 377 | + # built through `.#bb`. | ||
| 378 | + packages = [ jolt pkgs.babashka (nixGLFor pkgs) ]; | ||
| 371 | 379 | ||
| 372 | # Read by scripts/run.bb rather than baked into a wrapper: the frq | 380 | # Read by scripts/run.bb rather than baked into a wrapper: the frq |
| 373 | # source `just run` runs is the working tree, so the launcher has | 381 | # source `just run` runs is the working tree, so the launcher has |
modified
justfile +3 -2 | @@ -1,6 +1,7 @@ | ||
| 1 | 1 | # Every recipe here is one line, because the work is in scripts/ — babashka |
| 2 | -# scripts, run through the pin in scripts/bb. A recipe body is a shell script | |
| 3 | -# nobody can run on its own; a script in scripts/ is a script. | |
| 2 | +# scripts, run through scripts/bb, which finds a bb the way this tree finds | |
| 3 | +# everything else. A recipe body is a shell script nobody can run on its own; | |
| 4 | +# a script in scripts/ is a script. | |
| 4 | 5 | |
| 5 | 6 | set shell := ["bash", "-euo", "pipefail", "-c"] |
| 6 | 7 | |
| @@ -1,6 +1,7 @@ | |||
| 1 | # Every recipe here is one line, because the work is in scripts/ — babashka | 1 | # Every recipe here is one line, because the work is in scripts/ — babashka |
| 2 | -# scripts, run through the pin in scripts/bb. A recipe body is a shell script | 2 | +# scripts, run through scripts/bb, which finds a bb the way this tree finds |
| 3 | -# nobody can run on its own; a script in scripts/ is a script. | 3 | +# everything else. A recipe body is a shell script nobody can run on its own; |
| 4 | +# a script in scripts/ is a script. | ||
| 4 | 5 | ||
| 5 | set shell := ["bash", "-euo", "pipefail", "-c"] | 6 | set shell := ["bash", "-euo", "pipefail", "-c"] |
| 6 | 7 | ||
modified
scripts/bb +49 -64 | @@ -1,65 +1,50 @@ | ||
| 1 | -#!/usr/bin/env dotslash | |
| 1 | +#!/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 | |
| 25 | +set -e | |
| 2 | 26 | |
| 3 | -// babashka, which the scripts here are written in. | |
| 4 | -// | |
| 5 | -// A build script wants the things a shell is bad at — reading deps.edn, | |
| 6 | -// hashing a file set, holding a path in a variable without quoting it three | |
| 7 | -// times — and Clojure is already the language this repo is written in. Pinned | |
| 8 | -// like every other tool, so the script a person runs at a terminal is the one | |
| 9 | -// buck runs in an action. | |
| 10 | -// | |
| 11 | -// The static Linux builds, because a build machine's glibc is not ours to | |
| 12 | -// assume; macOS has no static option and does not need one. | |
| 13 | -{ | |
| 14 | - "name": "bb", | |
| 15 | - "platforms": { | |
| 16 | - "linux-x86_64": { | |
| 17 | - "size": 26177709, | |
| 18 | - "hash": "sha256", | |
| 19 | - "digest": "eb3edd128276f0b6fbdefcb18dc7d42652a95ea409a81b34f08e36b8ac3cbc3c", | |
| 20 | - "format": "tar.gz", | |
| 21 | - "path": "bb", | |
| 22 | - "providers": [ | |
| 23 | - { | |
| 24 | - "url": "https://github.com/babashka/babashka/releases/download/v1.13.220/babashka-1.13.220-linux-amd64-static.tar.gz" | |
| 25 | - } | |
| 26 | - ] | |
| 27 | - }, | |
| 28 | - "linux-aarch64": { | |
| 29 | - "size": 28271754, | |
| 30 | - "hash": "sha256", | |
| 31 | - "digest": "0efd6ef36b93ea2f0ae6ebf9d1bcd1a66167c2f41c17e990659aa067654437e8", | |
| 32 | - "format": "tar.gz", | |
| 33 | - "path": "bb", | |
| 34 | - "providers": [ | |
| 35 | - { | |
| 36 | - "url": "https://github.com/babashka/babashka/releases/download/v1.13.220/babashka-1.13.220-linux-aarch64-static.tar.gz" | |
| 37 | - } | |
| 38 | - ] | |
| 39 | - }, | |
| 40 | - "macos-x86_64": { | |
| 41 | - "size": 26050398, | |
| 42 | - "hash": "sha256", | |
| 43 | - "digest": "ebbfdf159e8d5ee8b7015b15c6558b2039fe76478de893cf317c8c50805340de", | |
| 44 | - "format": "tar.gz", | |
| 45 | - "path": "bb", | |
| 46 | - "providers": [ | |
| 47 | - { | |
| 48 | - "url": "https://github.com/babashka/babashka/releases/download/v1.13.220/babashka-1.13.220-macos-amd64.tar.gz" | |
| 49 | - } | |
| 50 | - ] | |
| 51 | - }, | |
| 52 | - "macos-aarch64": { | |
| 53 | - "size": 26548984, | |
| 54 | - "hash": "sha256", | |
| 55 | - "digest": "f7d18c3ab11bb4ad0e32a45c1ae40ae25911d5fa06ba4ded07cb90b8af158077", | |
| 56 | - "format": "tar.gz", | |
| 57 | - "path": "bb", | |
| 58 | - "providers": [ | |
| 59 | - { | |
| 60 | - "url": "https://github.com/babashka/babashka/releases/download/v1.13.220/babashka-1.13.220-macos-aarch64.tar.gz" | |
| 61 | - } | |
| 62 | - ] | |
| 63 | - } | |
| 64 | - } | |
| 65 | -} | |
| 27 | +root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) | |
| 28 | + | |
| 29 | +if command -v bb >/dev/null 2>&1; then | |
| 30 | + exec bb "$@" | |
| 31 | +fi | |
| 32 | + | |
| 33 | +link="$root/build/bb" | |
| 34 | + | |
| 35 | +if 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" "$@" | |
| 41 | +fi | |
| 42 | + | |
| 43 | +if [ -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 | |
| 47 | +fi | |
| 48 | + | |
| 49 | +exec distrobox enter arch -- bash -lc \ | |
| 50 | + "cd $root && FRQ_BB_REENTERED=1 exec scripts/bb \"\$@\"" -- "$@" | |
| @@ -1,65 +1,50 @@ | |||
| 1 | -#!/usr/bin/env dotslash | 1 | +#!/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 | ||
| 25 | +set -e | ||
| 2 | 26 | ||
| 3 | -// babashka, which the scripts here are written in. | 27 | +root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) |
| 4 | -// | 28 | + |
| 5 | -// A build script wants the things a shell is bad at — reading deps.edn, | 29 | +if command -v bb >/dev/null 2>&1; then |
| 6 | -// hashing a file set, holding a path in a variable without quoting it three | 30 | + exec bb "$@" |
| 7 | -// times — and Clojure is already the language this repo is written in. Pinned | 31 | +fi |
| 8 | -// like every other tool, so the script a person runs at a terminal is the one | 32 | + |
| 9 | -// buck runs in an action. | 33 | +link="$root/build/bb" |
| 10 | -// | 34 | + |
| 11 | -// The static Linux builds, because a build machine's glibc is not ours to | 35 | +if command -v nix >/dev/null 2>&1; then |
| 12 | -// assume; macOS has no static option and does not need one. | 36 | + # --out-link rather than --no-link: the path has to survive a gc, and the |
| 13 | -{ | 37 | + # symlink is what roots it. Rebuilt only when it is gone or dangling, so |
| 14 | - "name": "bb", | 38 | + # the usual case is one readlink. |
| 15 | - "platforms": { | 39 | + [ -x "$link/bin/bb" ] || nix build "$root#bb" --out-link "$link" >&2 |
| 16 | - "linux-x86_64": { | 40 | + exec "$link/bin/bb" "$@" |
| 17 | - "size": 26177709, | 41 | +fi |
| 18 | - "hash": "sha256", | 42 | + |
| 19 | - "digest": "eb3edd128276f0b6fbdefcb18dc7d42652a95ea409a81b34f08e36b8ac3cbc3c", | 43 | +if [ -n "$FRQ_BB_REENTERED" ]; then |
| 20 | - "format": "tar.gz", | 44 | + echo "scripts/bb: no bb and no nix, inside the container too." >&2 |
| 21 | - "path": "bb", | 45 | + echo "Install babashka, or put a nix on this machine." >&2 |
| 22 | - "providers": [ | 46 | + exit 1 |
| 23 | - { | 47 | +fi |
| 24 | - "url": "https://github.com/babashka/babashka/releases/download/v1.13.220/babashka-1.13.220-linux-amd64-static.tar.gz" | 48 | + |
| 25 | - } | 49 | +exec distrobox enter arch -- bash -lc \ |
| 26 | - ] | 50 | + "cd $root && FRQ_BB_REENTERED=1 exec scripts/bb \"\$@\"" -- "$@" |
| 27 | - }, | ||
| 28 | - "linux-aarch64": { | ||
| 29 | - "size": 28271754, | ||
| 30 | - "hash": "sha256", | ||
| 31 | - "digest": "0efd6ef36b93ea2f0ae6ebf9d1bcd1a66167c2f41c17e990659aa067654437e8", | ||
| 32 | - "format": "tar.gz", | ||
| 33 | - "path": "bb", | ||
| 34 | - "providers": [ | ||
| 35 | - { | ||
| 36 | - "url": "https://github.com/babashka/babashka/releases/download/v1.13.220/babashka-1.13.220-linux-aarch64-static.tar.gz" | ||
| 37 | - } | ||
| 38 | - ] | ||
| 39 | - }, | ||
| 40 | - "macos-x86_64": { | ||
| 41 | - "size": 26050398, | ||
| 42 | - "hash": "sha256", | ||
| 43 | - "digest": "ebbfdf159e8d5ee8b7015b15c6558b2039fe76478de893cf317c8c50805340de", | ||
| 44 | - "format": "tar.gz", | ||
| 45 | - "path": "bb", | ||
| 46 | - "providers": [ | ||
| 47 | - { | ||
| 48 | - "url": "https://github.com/babashka/babashka/releases/download/v1.13.220/babashka-1.13.220-macos-amd64.tar.gz" | ||
| 49 | - } | ||
| 50 | - ] | ||
| 51 | - }, | ||
| 52 | - "macos-aarch64": { | ||
| 53 | - "size": 26548984, | ||
| 54 | - "hash": "sha256", | ||
| 55 | - "digest": "f7d18c3ab11bb4ad0e32a45c1ae40ae25911d5fa06ba4ded07cb90b8af158077", | ||
| 56 | - "format": "tar.gz", | ||
| 57 | - "path": "bb", | ||
| 58 | - "providers": [ | ||
| 59 | - { | ||
| 60 | - "url": "https://github.com/babashka/babashka/releases/download/v1.13.220/babashka-1.13.220-macos-aarch64.tar.gz" | ||
| 61 | - } | ||
| 62 | - ] | ||
| 63 | - } | ||
| 64 | - } | ||
| 65 | -} | ||