Crate nix_installer

source ·
Expand description

The Determinate Nix Installer

nix-installer breaks down into three main concepts:

  • Action: An executable or revertable step, possibly orcestrating sub-Actions using things like JoinSets.
  • InstallPlan: A set of Actions, along with some metadata, which can be carried out to drive an install or revert.
  • Planner: Something which can be used to plan out an InstallPlan.

It is possible to create custom Actions and Planners to suit the needs of your project, team, or organization.

In the simplest case, nix-installer can be asked to determine a default plan for the platform and install it, uninstalling if anything goes wrong:

use std::error::Error;
use nix_installer::InstallPlan;

let mut plan = InstallPlan::default().await?;
match plan.install(None).await {
    Ok(()) => tracing::info!("Done"),
    Err(e) => {
        match e.source() {
            Some(source) => tracing::error!("{e}: {}", source),
            None => tracing::error!("{e}"),
        };
        plan.uninstall(None).await?;
    },
};

Sometimes choosing a specific planner is desired:

use std::error::Error;
use nix_installer::{InstallPlan, planner::Planner};

#[cfg(target_os = "linux")]
let planner = nix_installer::planner::steam_deck::SteamDeck::default().await?;
#[cfg(target_os = "macos")]
let planner = nix_installer::planner::macos::Macos::default().await?;

// Or call `crate::planner::BuiltinPlanner::default()`
// Match on the result to customize.

// Customize any settings...

let mut plan = InstallPlan::plan(planner).await?;
match plan.install(None).await {
    Ok(()) => tracing::info!("Done"),
    Err(e) => {
        match e.source() {
            Some(source) => tracing::error!("{e}: {}", source),
            None => tracing::error!("{e}"),
        };
        plan.uninstall(None).await?;
    },
};

Modules

An executable or revertable step, possibly orcestrating sub-Actions using things like JoinSets
CLI argument structures and utilities
BuiltinPlanners and traits to create new types which can be used to plan out an InstallPlan
Configurable knobs and their related errors

Structs

A pair of String and Url destined for the list of subscribed channels for nix-channel
A set of Actions, along with some metadata, which can be carried out to drive an install or revert

Enums

An error occurring during a call defined in this crate