sigildocs

(sigil store)

Exports

storeprocedure

Construct a store struct.

store?procedure

Test if a value is a store struct.

store-dirprocedure

Get the dir field of a store struct.

store-dbprocedure

Get the db field of a store struct.

Return 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-storeprocedure

Open 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-storeprocedure

Close a store, releasing the database connection.

with-storeprocedure

Call 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-pathprocedure

Return the filesystem path of the store directory.

Add 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"

Add 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.

Add content from a string or bytevector.

store-valid?procedure

Check 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).

Return the full filesystem path for a store path.

Raises an error if the item doesn't exist.

Return the references (dependencies) of a store item.

Return all items that reference a given store path.

store-listprocedure

List all valid store paths.

List all valid store paths.

derivationprocedure

Construct a derivation struct.

derivation?procedure

Test if a value is a derivation struct.

Get the name field of a derivation struct.

Get the system field of a derivation struct.

Get the inputs field of a derivation struct.

Get the builder field of a derivation struct.

Get the args field of a derivation struct.

Get the hash field of a derivation struct.

Get the output field of a derivation struct.

Register 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))))

Create 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-buildprocedure

Build 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"

Register 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"

Register 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)

Remove a GC root by name.

store-rootsprocedure

List all GC roots.

Returns a list of alists with name, itempath, and createdat.

store-gcprocedure

Delete 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-statsprocedure

Report store size and item count.

(store-stats s)
; => ((count . 150) (size . 52428800))

Copy or hardlink a store item to a destination path.

Tries hardlink first, falls back to copy.

hash-filevariable

(No description)

hash-datavariable

(No description)

(No description)