Something went wrong. Try again.
Blazing flast deployments for NixOS + nix-darwin.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071use serde::Deserialize;use std::collections::HashMap;use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]pub enum SystemType { Nixos, Darwin,}
impl SystemType { pub fn parse(s: &str) -> Result<Self, String> { match s { "nixos" => Ok(SystemType::Nixos), "darwin" => Ok(SystemType::Darwin), other => Err(format!("unsupported system type: {other}")), } }}
impl fmt::Display for SystemType { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { SystemType::Nixos => write!(f, "nixos"), SystemType::Darwin => write!(f, "darwin"), } }}
#[derive(Debug, Clone)]pub struct JobSpec { pub hostname: String, pub system: SystemType, pub user: String, pub drv_path: String,}
impl JobSpec { /// The SSH target string (`user@hostname`) for this deployment. pub fn target(&self) -> String { format!("{}@{}", self.user, self.hostname) }}
/// One entry from `nix build --json`.#[derive(Debug, Clone, Deserialize)]pub struct BuildResult { pub outputs: HashMap<String, String>,}
/// One JSON-Lines record emitted by `nix-eval-jobs`.#[derive(Debug, Clone, Deserialize)]#[serde(rename_all = "camelCase")]pub struct NixEvalJobsResult { pub attr: String, pub attr_path: Option<Vec<String>>, pub drv_path: Option<String>, pub error: Option<String>, pub extra_value: Option<NodeMetadata>, pub outputs: Option<HashMap<String, String>>, pub system: Option<String>,}
#[derive(Debug, Clone, Default, Deserialize)]pub struct NodeMetadata { pub hostname: Option<String>, pub user: Option<String>, #[serde(rename = "type")] pub type_name: Option<String>,}