ALPHA: wire is a tool to deploy nixos systems wire.althaea.zone/
at stable 71 lines 1.5 kB view raw
1// SPDX-License-Identifier: AGPL-3.0-or-later 2// Copyright 2024-2025 wire Contributors 3 4#![feature(assert_matches)] 5#![feature(iter_intersperse)] 6#![feature(sync_nonpoison)] 7#![feature(nonpoison_mutex)] 8 9use std::{ 10 io::{IsTerminal, stderr}, 11 sync::LazyLock, 12}; 13 14use tokio::sync::{AcquireError, Semaphore, SemaphorePermit}; 15 16use crate::{errors::HiveLibError, hive::node::Name, status::STATUS}; 17 18pub mod cache; 19pub mod commands; 20pub mod hive; 21pub mod status; 22 23#[cfg(test)] 24mod test_macros; 25 26#[cfg(test)] 27mod test_support; 28 29pub mod errors; 30 31#[derive(Clone, Debug, Copy, Default)] 32pub enum StrictHostKeyChecking { 33 /// do not accept new host. dangerous! 34 No, 35 36 /// accept-new, default 37 #[default] 38 AcceptNew, 39} 40 41#[derive(Debug, Clone, Copy)] 42pub struct SubCommandModifiers { 43 pub show_trace: bool, 44 pub non_interactive: bool, 45 pub ssh_accept_host: StrictHostKeyChecking, 46} 47 48impl Default for SubCommandModifiers { 49 fn default() -> Self { 50 SubCommandModifiers { 51 show_trace: false, 52 non_interactive: !std::io::stdin().is_terminal(), 53 ssh_accept_host: StrictHostKeyChecking::default(), 54 } 55 } 56} 57 58pub enum EvalGoal<'a> { 59 Inspect, 60 Names, 61 GetTopLevel(&'a Name), 62} 63 64pub static STDIN_CLOBBER_LOCK: LazyLock<Semaphore> = LazyLock::new(|| Semaphore::new(1)); 65 66pub async fn acquire_stdin_lock<'a>() -> Result<SemaphorePermit<'a>, AcquireError> { 67 let result = STDIN_CLOBBER_LOCK.acquire().await?; 68 STATUS.lock().wipe_out(&mut stderr()); 69 70 Ok(result) 71}