| Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago | 1 | #!/bin/sh |
| 2 | #_( |
| 3 | exec "$(dirname "$0")/bb" "$0" "$@" |
| 4 | ) |
| 5 | |
| Run the source on disk, not the source in git 66ba416 nandi 17d ago | 6 | ;; The app, from this working tree. |
| Run the app the way it is built: nix run 35e7155 nandi 17d ago | 7 | ;; |
| 8 | ;; run.bb [args...] |
| 9 | ;; |
| Run the source on disk, not the source in git 66ba416 nandi 17d ago | 10 | ;; Everything but the source is pinned: jolt comes from scripts/jolt.dotslash |
| 11 | ;; and the two native libraries from scripts/lib*.dotslash, fetched by digest |
| 12 | ;; and linked into build/lib, which is the one directory the loader is pointed |
| 13 | ;; at. `just lib` is done here rather than asked for — the pins say what those |
| 14 | ;; bytes are, so there is nothing for a person to decide before running. |
| Run the app the way it is built: nix run 35e7155 nandi 17d ago | 15 | ;; |
| Run the source on disk, not the source in git 66ba416 nandi 17d ago | 16 | ;; Deliberately not `nix run .#frq`. That builds the flake's own copy of the |
| 17 | ;; source, which is the tree as git has it — so an edit that has not been |
| 18 | ;; committed, or has been committed on a branch the command was not pointed at, |
| 19 | ;; runs as whatever was there before, silently. A run that is meant to answer |
| 20 | ;; "does my change work" has to be the files on disk. |
| 21 | (require '[babashka.fs :as fs] |
| 22 | '[babashka.process :as p]) |
| Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago | 23 | |
| 24 | (def root (str (fs/canonicalize (fs/path (fs/parent *file*) "..")))) |
| Run the source on disk, not the source in git 66ba416 nandi 17d ago | 25 | (def lib (str (fs/path root "build" "lib"))) |
| Run the app the way it is built: nix run 35e7155 nandi 17d ago | 26 | |
| Run the source on disk, not the source in git 66ba416 nandi 17d ago | 27 | ;; The pinned jolt — scripts/jolt is a DotSlash script, so running it is |
| 28 | ;; fetching it. Off linux-x86_64 the pin has no asset and the fallback is |
| 29 | ;; whatever `jolt` is on PATH, which is what that manifest says to do. |
| 30 | (def jolt |
| 31 | (let [pin (fs/path root "scripts" "jolt")] |
| 32 | (if (and (fs/exists? pin) (fs/which "dotslash")) (str pin) "jolt"))) |
| Run the app the way it is built: nix run 35e7155 nandi 17d ago | 33 | |
| Run the source on disk, not the source in git 66ba416 nandi 17d ago | 34 | (p/shell (str (fs/path root "scripts" "lib.bb"))) |
| Write the build in babashka, and pin the babashka 34832a8 nandi 18d ago | 35 | |
| 36 | (System/exit |
| Run the source on disk, not the source in git 66ba416 nandi 17d ago | 37 | (:exit @(apply p/process |
| 38 | {:inherit true |
| 39 | :dir root |
| 40 | :extra-env {"LD_LIBRARY_PATH" |
| 41 | (str lib (when-let [p (System/getenv "LD_LIBRARY_PATH")] |
| 42 | (str ":" p)))}} |
| 43 | jolt "-M:frq" *command-line-args*))) |