Skip to main content

Module bridge

Module bridge 

Source
Expand description

Builtin bridge: tree-walker builtins callable from the VM. Builtin bridge: allows the bytecode VM to call tree-walker builtins.

The VM has native implementations for ~103 builtins, but nixpkgs needs ~119+. Instead of reimplementing every builtin in the VM’s value system, this module provides a callback mechanism that delegates to the tree-walker’s builtins for any builtin the VM doesn’t handle natively.

§Architecture

Follows the same pattern as set_flake_resolver in vm.rs: a thread-local callback with an RAII guard for cleanup.

sui-eval (BytecodeEvaluator)
  │
  ├─ set_builtin_bridge(callback)  ← installs bridge before VM eval
  │
  └─ VM execution
      │
      └─ CallBuiltin for "getEnv" etc.
          │
          └─ BuiltinRegistry stub → call_builtin_bridge("getEnv", args)
              │
              └─ callback converts VMValue↔Value, calls tree-walker builtin

Structs§

BuiltinBridgeGuard
RAII guard that restores the previous builtin bridge on drop.
PathMaterializerGuard
RAII guard that restores the previous path materializer on drop.

Functions§

call_builtin_bridge
Call the builtin bridge for a named builtin.
materialize
Redirect a path through the installed materializer.
materialize_path
materialize for a &Path, returning an owned PathBuf.
set_builtin_bridge
Install a builtin bridge callback for the current thread.
set_path_materializer
Install a path materializer for the current thread.

Type Aliases§

BuiltinBridgeFn
Callback type for bridging tree-walker builtins into the VM.
PathMaterializerFn
Callback type for redirecting a filesystem path before it is read.