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 as a subprocess with a
Nix-pinned runtime (e.g. nix run nixpkgs#python3 -- stage.py). The Nix
binary cache ensures the runtime is downloaded once and then reused from
the store. This gives reproducibility, not isolation: the subprocess
inherits the host user’s privileges, filesystem, and network. See module
docs and SECURITY.md for the full trust model.
§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 config_snapshot(&self) -> NixConfig
pub fn config_snapshot(&self) -> NixConfig
Clone the current config (minus the implementations map) for callers that want to rebuild with different knobs.
Sourcepub fn rebuild_with_config(self, config: NixConfig) -> Option<Self>
pub fn rebuild_with_config(self, config: NixConfig) -> Option<Self>
Rebuild a NixExecutor with a replacement config, preserving
its registered implementations. Returns Some(..) or None
when reconstruction fails — today it can’t fail, but the
Option keeps the API forward-compatible.
Sourcepub fn register_with_effects(
&mut self,
stage_id: &StageId,
code: &str,
language: &str,
effects: EffectSet,
)
pub fn register_with_effects( &mut self, stage_id: &StageId, code: &str, language: &str, effects: EffectSet, )
Register a stage with explicit declared effects. Used by tests and by callers that want to drive the isolation policy without going through the full StageStore.
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.