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

Run the app the way it is built: nix run 35e7155 · on bccb13490b96a3c38937528bc4ea07c8f11e3e2a · nandi · 17d ago
run.bb · 51 lines · 1.8 KBBlitzBasic Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
#_(
exec "$(dirname "$0")/bb" "$0" "$@"
)

;; The app.
;;
;;   run.bb [args...]
;;
;; `nix run .#frq`, which is the whole build: the native libraries, the jolt
;; runtime, the dependency graph, and a launcher that puts nixGL in front off
;; NixOS so the window opens. Nothing here needs `just lib` first.
;;
;; Nix is not on every host that has this checkout — on the developer's it
;; lives in the Arch distrobox — so a host without it is not an error, it is
;; the same command run one layer in. The worktree path is the same inside the
;; container as outside, which is what lets the `cd` be this path verbatim.
(require '[babashka.classpath :as cp])
(cp/add-classpath (str (babashka.fs/parent *file*)))
(require '[frq.paths :as paths]
         '[babashka.fs :as fs]
         '[babashka.process :as p]
         '[clojure.string :as str])

(def root (str (fs/canonicalize (fs/path (fs/parent *file*) ".."))))
(def box (paths/env "FRQ_DISTROBOX" "arch"))

(defn quote-arg
  "One argument, safe for a shell that will read the whole line as a string."
  [s]
  (str "'" (str/replace (str s) "'" "'\\''") "'"))

;; `--` and then the args: everything past it is the app's, not nix's.
(def nix-args
  (concat ["nix" "run" ".#frq"]
          (when (seq *command-line-args*) (cons "--" *command-line-args*))))

(def command
  (if (fs/which "nix")
    (cons {:dir root} nix-args)
    (do
      (when-not (fs/which "distrobox")
        (paths/die "no nix and no distrobox — install nix, or set FRQ_DISTROBOX"
                   "to a container that has it."))
      [{} "distrobox" "enter" box "--"
       "bash" "-lc" (str "cd " (quote-arg root) " && "
                         (str/join " " (map quote-arg nix-args)))])))

(System/exit
 (:exit @(apply p/process (assoc (first command) :inherit true)
                (rest command))))