Run the app the way it is built: nix run
The old run.bb ran a bare `jolt -M:frq` with build/lib on the loader path, which only worked after `just lib` had put the native release there — a second way of assembling the app beside the flake's, and the one that goes stale. `nix run .#frq` is the whole thing: the libraries, the jolt runtime, the resolved graph, and the launcher that puts nixGL in front off NixOS. Nix is not on every host holding this checkout — on this one it lives in the Arch distrobox — so a host without it is not an error, just the same command one layer in. The worktree path is identical inside the container, which is what lets the cd be the path verbatim. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
35e7155 parent: da84772 modified
scripts/run.bb +42 -10 | @@ -3,17 +3,49 @@ | ||
| 3 | 3 | exec "$(dirname "$0")/bb" "$0" "$@" |
| 4 | 4 | ) |
| 5 | 5 | |
| 6 | -;; The app, with the native libraries `just lib` linked into build/lib on the | |
| 7 | -;; loader path. Those are jolt-native's release, fetched by digest; nothing | |
| 8 | -;; here looks for a checkout of it. | |
| 9 | -(require '[babashka.fs :as fs] | |
| 10 | - '[babashka.process :as p]) | |
| 6 | +;; The app. | |
| 7 | +;; | |
| 8 | +;; run.bb [args...] | |
| 9 | +;; | |
| 10 | +;; `nix run .#frq`, which is the whole build: the native libraries, the jolt | |
| 11 | +;; runtime, the dependency graph, and a launcher that puts nixGL in front off | |
| 12 | +;; NixOS so the window opens. Nothing here needs `just lib` first. | |
| 13 | +;; | |
| 14 | +;; Nix is not on every host that has this checkout — on the developer's it | |
| 15 | +;; lives in the Arch distrobox — so a host without it is not an error, it is | |
| 16 | +;; the same command run one layer in. The worktree path is the same inside the | |
| 17 | +;; container as outside, which is what lets the `cd` be this path verbatim. | |
| 18 | +(require '[babashka.classpath :as cp]) | |
| 19 | +(cp/add-classpath (str (babashka.fs/parent *file*))) | |
| 20 | +(require '[frq.paths :as paths] | |
| 21 | + '[babashka.fs :as fs] | |
| 22 | + '[babashka.process :as p] | |
| 23 | + '[clojure.string :as str]) | |
| 11 | 24 | |
| 12 | 25 | (def root (str (fs/canonicalize (fs/path (fs/parent *file*) "..")))) |
| 26 | +(def box (paths/env "FRQ_DISTROBOX" "arch")) | |
| 27 | + | |
| 28 | +(defn quote-arg | |
| 29 | + "One argument, safe for a shell that will read the whole line as a string." | |
| 30 | + [s] | |
| 31 | + (str "'" (str/replace (str s) "'" "'\\''") "'")) | |
| 32 | + | |
| 33 | +;; `--` and then the args: everything past it is the app's, not nix's. | |
| 34 | +(def nix-args | |
| 35 | + (concat ["nix" "run" ".#frq"] | |
| 36 | + (when (seq *command-line-args*) (cons "--" *command-line-args*)))) | |
| 37 | + | |
| 38 | +(def command | |
| 39 | + (if (fs/which "nix") | |
| 40 | + (cons {:dir root} nix-args) | |
| 41 | + (do | |
| 42 | + (when-not (fs/which "distrobox") | |
| 43 | + (paths/die "no nix and no distrobox — install nix, or set FRQ_DISTROBOX" | |
| 44 | + "to a container that has it.")) | |
| 45 | + [{} "distrobox" "enter" box "--" | |
| 46 | + "bash" "-lc" (str "cd " (quote-arg root) " && " | |
| 47 | + (str/join " " (map quote-arg nix-args)))]))) | |
| 13 | 48 | |
| 14 | 49 | (System/exit |
| 15 | - (:exit @(apply p/process | |
| 16 | - {:inherit true | |
| 17 | - :extra-env {"LD_LIBRARY_PATH" | |
| 18 | - (str (fs/path root "build" "lib"))}} | |
| 19 | - "jolt" "-M:frq" *command-line-args*))) | |
| 50 | + (:exit @(apply p/process (assoc (first command) :inherit true) | |
| 51 | + (rest command)))) | |
| @@ -3,17 +3,49 @@ | |||
| 3 | exec "$(dirname "$0")/bb" "$0" "$@" | 3 | exec "$(dirname "$0")/bb" "$0" "$@" |
| 4 | ) | 4 | ) |
| 5 | 5 | ||
| 6 | -;; The app, with the native libraries `just lib` linked into build/lib on the | 6 | +;; The app. |
| 7 | -;; loader path. Those are jolt-native's release, fetched by digest; nothing | 7 | +;; |
| 8 | -;; here looks for a checkout of it. | 8 | +;; run.bb [args...] |
| 9 | -(require '[babashka.fs :as fs] | 9 | +;; |
| 10 | - '[babashka.process :as p]) | 10 | +;; `nix run .#frq`, which is the whole build: the native libraries, the jolt |
| 11 | +;; runtime, the dependency graph, and a launcher that puts nixGL in front off | ||
| 12 | +;; NixOS so the window opens. Nothing here needs `just lib` first. | ||
| 13 | +;; | ||
| 14 | +;; Nix is not on every host that has this checkout — on the developer's it | ||
| 15 | +;; lives in the Arch distrobox — so a host without it is not an error, it is | ||
| 16 | +;; the same command run one layer in. The worktree path is the same inside the | ||
| 17 | +;; container as outside, which is what lets the `cd` be this path verbatim. | ||
| 18 | +(require '[babashka.classpath :as cp]) | ||
| 19 | +(cp/add-classpath (str (babashka.fs/parent *file*))) | ||
| 20 | +(require '[frq.paths :as paths] | ||
| 21 | + '[babashka.fs :as fs] | ||
| 22 | + '[babashka.process :as p] | ||
| 23 | + '[clojure.string :as str]) | ||
| 11 | 24 | ||
| 12 | (def root (str (fs/canonicalize (fs/path (fs/parent *file*) "..")))) | 25 | (def root (str (fs/canonicalize (fs/path (fs/parent *file*) "..")))) |
| 26 | +(def box (paths/env "FRQ_DISTROBOX" "arch")) | ||
| 27 | + | ||
| 28 | +(defn quote-arg | ||
| 29 | + "One argument, safe for a shell that will read the whole line as a string." | ||
| 30 | + [s] | ||
| 31 | + (str "'" (str/replace (str s) "'" "'\\''") "'")) | ||
| 32 | + | ||
| 33 | +;; `--` and then the args: everything past it is the app's, not nix's. | ||
| 34 | +(def nix-args | ||
| 35 | + (concat ["nix" "run" ".#frq"] | ||
| 36 | + (when (seq *command-line-args*) (cons "--" *command-line-args*)))) | ||
| 37 | + | ||
| 38 | +(def command | ||
| 39 | + (if (fs/which "nix") | ||
| 40 | + (cons {:dir root} nix-args) | ||
| 41 | + (do | ||
| 42 | + (when-not (fs/which "distrobox") | ||
| 43 | + (paths/die "no nix and no distrobox — install nix, or set FRQ_DISTROBOX" | ||
| 44 | + "to a container that has it.")) | ||
| 45 | + [{} "distrobox" "enter" box "--" | ||
| 46 | + "bash" "-lc" (str "cd " (quote-arg root) " && " | ||
| 47 | + (str/join " " (map quote-arg nix-args)))]))) | ||
| 13 | 48 | ||
| 14 | (System/exit | 49 | (System/exit |
| 15 | - (:exit @(apply p/process | 50 | + (:exit @(apply p/process (assoc (first command) :inherit true) |
| 16 | - {:inherit true | 51 | + (rest command)))) |
| 17 | - :extra-env {"LD_LIBRARY_PATH" | ||
| 18 | - (str (fs/path root "build" "lib"))}} | ||
| 19 | - "jolt" "-M:frq" *command-line-args*))) | ||