Babashka

Why Babashka?

Babashka is one of the gems of the Clojure community. Plain Clojure isn’t suitable for many use cases because the startup time is too slow. This becomes apparently soon after an aspiring Clojure developer starts trying to use it in place of an unmaintainable pile of Bash scripts.

Deb file

On Debian, it is proper to use deb files to add/remove binaries. Therefore I packaged babashka myself (I have my own set of deb files that I use and I need a packaged version to track dependencies properly). This isn’t a proper Debian package - to get into the archive, it is expected that a package will include enough information to be built from the source. I’m not going that far (not sure how to set up GraalVM) - this package only copies bb into /usr/bin. AMD64 binary only.

$ b3sum babashka_1.3.186-1_amd64.deb
ea7da1feff7c9e74de0726f737a96a2baed0a06029e08c6fafe3dcd18abf80e6  babashka_1.3.186-1_amd64.deb
$ dpkg -i babashka_1.3.186-1_amd64.deb
...
$ dpkg -L babashka 
/.
/usr
/usr/bin
/usr/bin/bb
/usr/share
/usr/share/doc
/usr/share/doc/babashka
/usr/share/doc/babashka/changelog.Debian.gz
/usr/share/doc/babashka/copyright
$ bb
Babashka v1.3.186 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> 

RAID v. Babashka

I have a RAID array that often resyncs at awkward times. I wrote a babashka script to calm it down so the system is still usable during a resync:

#!/usr/bin/bb

(require '[babashka.fs :as fs])

(def sync-seq (fs/match "/sys/block/" "glob:md*/md/sync_speed_max" {:follow-links true :max-depth 3 :recursive true}))

(doseq [f sync-seq] (spit (fs/file f) "30000"))

(prn 
 (for [f sync-seq] (slurp (fs/file f))))