Skip to main content

NixBackend

Struct NixBackend 

Source
pub struct NixBackend {
    pub indent_width: usize,
}
Expand description

The Nix code generation backend.

Converts OxiLean IR constructs into Nix expression language output.

Fields§

§indent_width: usize

Indent width (default 2)

Implementations§

Source§

impl NixBackend

Source

pub fn new() -> Self

Create a new NixBackend with default settings.

Source

pub fn emit_expr(&self, expr: &NixExpr, indent: usize) -> String

Emit a NixExpr at the given indentation level.

Source

pub fn emit_module(&self, module: &NixModule) -> String

Emit a complete NixModule as a .nix file string.

Source

pub fn emit_attr(&self, attr: &NixAttr, indent: usize) -> String

Emit a NixAttr binding.

Source

pub fn emit_function(&self, func: &NixFunction, indent: usize) -> String

Emit a NixFunction.

Source

pub fn make_derivation( &self, name: &str, version: &str, src: NixExpr, build_inputs: Vec<NixExpr>, build_phase: Option<&str>, install_phase: Option<&str>, extra_attrs: Vec<NixAttr>, ) -> NixExpr

Build a mkDerivation call from common parameters.

Source

pub fn make_nixos_module( &self, module_args: Vec<(String, Option<NixExpr>)>, options: Vec<NixAttr>, config: Vec<NixAttr>, ) -> NixModule

Build a NixOS module skeleton with options and config sections.

Source

pub fn make_overlay(&self, attrs: Vec<NixAttr>) -> NixExpr

Build an overlay expression: final: prev: { ... }

Source

pub fn make_flake( &self, description: &str, outputs_attrs: Vec<NixAttr>, ) -> NixExpr

Build a flake.nix-style output expression skeleton.

Trait Implementations§

Source§

impl Default for NixBackend

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.