Liking cljdoc? Tell your friends :D

rift-clojure

Clojars Project CI

Clojure binding to rift — copy-on-write development workspaces, a faster alternative to git worktree (instant, near-zero disk via APFS clonefile on macOS / btrfs snapshots on Linux).

It loads rift's native librift_ffi in-process through the JDK Foreign Function & Memory API (java.lang.foreign) — no subprocess, no JNI. Same shared library rift ships for Bun/Node, called from the JVM.

⚠️ rift is experimental. This is a vendored binding: its version tracks the rift release 1:1 — com.blockether/rift X.Y.Z targets rift vX.Y.Z.

Install

com.blockether/rift {:mvn/version "0.0.10"}

Native loading is automatic: com.blockether/rift first checks RIFT_NATIVE_PATH, then any classpath native jar, then downloads com.blockether/rift-native-<platform> from Clojars into ~/.cache/clj-rift. You can also add the native jar explicitly, e.g. com.blockether/rift-native-linux-x64 {:mvn/version "0.0.8"}.

Run the JVM with native access enabled (else the linker refuses to load the lib):

--enable-native-access=ALL-UNNAMED

Usage

(require '[com.blockether.rift :as rift])

(rift/init   {:at "/repo"})                         ; register a rift root
(def ws (rift/create {:from "/repo" :name "fix"}))  ; => CoW copy path
(rift/list      {:of "/repo"})                      ; => direct children
(rift/ancestors {:of ws})                           ; => parents, nearest first
(rift/remove!   {:at ws})                            ; trash it
(rift/gc)                                            ; delete trashed storage

Every fn takes an optional :database (rift's SQLite registry). Set a default once instead of repeating it:

(rift/set-default-database! "/path/to/rift.sqlite")  ; process-wide
(rift/with-database "/tmp/test.sqlite" …)            ; scoped

Precedence: explicit :database > with-database > set-default-database! > platform default ((rift/default-database)).

Errors are ex-info with {:type :rift/error :code <string> :path <string?>} (cow_unavailable, workspace_not_initialized, already_exists, …).

Platforms

PlatformLibraryBackend
darwin-arm64librift_ffi.dylibAPFS clonefile
darwin-x64librift_ffi.dylibAPFS clonefile
linux-x64librift_ffi.sobtrfs snapshots
linux-arm64librift_ffi.sobtrfs snapshots

Linux CoW requires a btrfs filesystem.

Develop

clojure -X:test          # run the test suite
clojure -T:build jar     # build the tiny main jar
clojure -T:build native-jar :platform darwin-arm64 # build one native jar
clojure -T:build install # install to ~/.m2

License

MIT (matching rift); vendored librift_ffi binaries © the rift authors, MIT.

Can you improve this documentation? These fine people already did:
Karol Wojcik & blockether-deployer
Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close