pub struct NixExecutor { /* private fields */ }Expand description
Executor that runs synthesized stages through Nix-managed language runtimes.
When nix is available, each stage is executed inside a hermetically isolated
subprocess (e.g. nix run nixpkgs#python3 -- stage.py). The Nix binary cache
ensures the runtime is downloaded once and then reused forever from the store.
§Resource limits
- Timeout: configured via
NixConfig::timeout_secs(default 30 s). The child is sent SIGKILL when the limit is exceeded. - Output cap: configured via
NixConfig::max_output_bytes(default 10 MiB).
Implementations§
Source§impl NixExecutor
impl NixExecutor
Sourcepub fn find_nix() -> Option<PathBuf>
pub fn find_nix() -> Option<PathBuf>
Probe the system for a usable nix binary.
Returns the path if found, or None if Nix is not installed.
Sourcepub fn from_store(store: &dyn StageStore) -> Option<Self>
pub fn from_store(store: &dyn StageStore) -> Option<Self>
Build an executor that can run synthesized stages found in store.
Returns None when nix is not available — callers should fall back to
InlineExecutor exclusively in that case.
Sourcepub fn from_store_with_config(
store: &dyn StageStore,
config: NixConfig,
) -> Option<Self>
pub fn from_store_with_config( store: &dyn StageStore, config: NixConfig, ) -> Option<Self>
Like [from_store] but with a custom NixConfig.
Sourcepub fn register(&mut self, stage_id: &StageId, code: &str, language: &str)
pub fn register(&mut self, stage_id: &StageId, code: &str, language: &str)
Register an in-memory synthesized stage without re-querying the store.
Sourcepub fn has_implementation(&self, stage_id: &StageId) -> bool
pub fn has_implementation(&self, stage_id: &StageId) -> bool
True when we have a real implementation for this stage.
Sourcepub fn warmup(&self) -> JoinHandle<()>
pub fn warmup(&self) -> JoinHandle<()>
Pre-fetch the Python 3 runtime into the Nix store in a background thread.
The first time any Python stage runs, Nix may take several seconds to
download and verify the runtime closure. Calling warmup() at startup
overlaps that latency with application boot time.
The returned JoinHandle can be ignored — any error is logged to stderr
but does not affect correctness; the runtime will still be fetched on first
actual use.