(sigil store)
Exports
storeprocedureConstruct a store struct.
store?procedureTest if a value is a store struct.
store-dirprocedureGet the dir field of a store struct.
store-dbprocedureGet the db field of a store struct.
default-store-pathprocedureReturn the default store path.
Checks SIGIL_STORE env var, then $XDG_CACHE_HOME/sigil/store, then ~/.cache/sigil/store.
(default-store-path)
; => "/home/user/.cache/sigil/store"open-storeprocedureOpen or create a content-addressable store at the given path.
The store directory and SQLite database are created if they don't exist. Multiple processes can share a store safely (SQLite handles locking).
(define s (open-store (default-store-path)))close-storeprocedureClose a store, releasing the database connection.
with-storeprocedureCall proc with an open store, closing it after.
(with-store (default-store-path)
(lambda (s)
(store-add-file s "test.txt" "/path/to/test.txt")))store-pathprocedureReturn the filesystem path of the store directory.
store-add-fileprocedureAdd a file to the store by content hash.
Returns the store path. If an item with the same content hash and name already exists, returns the existing path without copying.
(store-add-file s "sigil-core.sgb" "/path/to/core.sgb")
; => "ab3f7c89...-sigil-core.sgb"store-add-directoryprocedureAdd a directory tree to the store by content hash.
The directory is serialized deterministically (sorted entries, no metadata) before hashing. The tree is copied into the store.
store-add-dataprocedureAdd content from a string or bytevector.
store-valid?procedureCheck whether a store path exists and is valid.
For files, verifies the size matches the DB record to detect corruption (e.g., 0-byte files from hard-link self-copy bugs).
store-realpathprocedureReturn the full filesystem path for a store path.
Raises an error if the item doesn't exist.
store-referencesprocedureReturn the references (dependencies) of a store item.
store-referrersprocedureReturn all items that reference a given store path.
store-listprocedureList all valid store paths.
%derivation--typevariableList all valid store paths.
derivationprocedureConstruct a derivation struct.
derivation?procedureTest if a value is a derivation struct.
derivation-nameprocedureGet the name field of a derivation struct.
derivation-systemprocedureGet the system field of a derivation struct.
derivation-inputsprocedureGet the inputs field of a derivation struct.
derivation-builderprocedureGet the builder field of a derivation struct.
derivation-argsprocedureGet the args field of a derivation struct.
derivation-hashprocedureGet the hash field of a derivation struct.
derivation-outputprocedureGet the output field of a derivation struct.
register-builder!procedureRegister a builder procedure by name.
The builder receives (store derivation output-dir) and should produce the output file/directory in output-dir.
(register-builder! 'compile-module
(lambda (store drv output-dir)
(compile-file (source drv) (output drv))))make-derivationvariableCreate a derivation describing how to produce an output from inputs.
The output store path is computed from the derivation hash — if the output already exists, the build is skipped.
(define drv
(make-derivation s
name: "sigil-core.sgb"
inputs: (list source-path dep1-path)
builder: 'compile-module
args: '((source . "core.sgl") (compiler-version . "0.8.0"))))store-buildprocedureBuild a derivation if its output doesn't already exist.
If the output store path is already valid, returns it immediately (cache hit). Otherwise, calls the builder to produce the output, adds it to the store, and returns the path.
(store-build s drv)
; => "ab3f7c89...-sigil-core.sgb"store-add-build-outputprocedureRegister a pre-built file as the output of a derivation.
Use this when compilation happens outside the store (e.g., by the build system), and the result needs to be cached at the derivation's deterministic output path.
(store-add-build-output s drv "/path/to/compiled.sgb")
; => "ab3f7c89...-compiled.sgb"store-add-rootprocedureRegister a GC root pointing to a store path.
Roots prevent an item and its transitive references from being garbage collected. NAME is a human-readable identifier.
(store-add-root s "dev-build" output-path)store-remove-rootprocedureRemove a GC root by name.
store-rootsprocedureList all GC roots.
Returns a list of alists with name, itempath, and createdat.
store-gcprocedureDelete all store items not reachable from any root.
Returns an alist with deleted count and bytes freed.
(store-gc s)
; => ((deleted . 42) (freed . 15728640))store-statsprocedureReport store size and item count.
(store-stats s)
; => ((count . 150) (size . 52428800))copy-from-storeprocedureCopy or hardlink a store item to a destination path.
Tries hardlink first, falls back to copy.
hash-filevariable(No description)
hash-datavariable(No description)
hash-directoryvariable(No description)