ALPHA: wire is a tool to deploy nixos systems wire.althaea.zone/
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

update `show` command to be nicer

+115 -7
+1
CHANGELOG.md
··· 39 39 the .drv is required 40 40 - A node which is going to be applied locally will now never `push` or 41 41 `cleanup`. 42 + - `show` subcommand looks nicer now. 42 43 43 44 ### Documented 44 45
+1
Cargo.lock
··· 952 952 "nix 0.30.1", 953 953 "nix-compat", 954 954 "num_enum", 955 + "owo-colors", 955 956 "portable-pty", 956 957 "proc-macro2", 957 958 "prost",
+1
Cargo.toml
··· 38 38 # "hints", 39 39 # ] } 40 40 serde_json = { version = "1.0.145" } 41 + owo-colors = { version = "4.2.3", features = ["supports-colors"] }
+1 -1
wire/cli/Cargo.toml
··· 27 27 dhat = "0.3.2" 28 28 clap_complete = "4.5.59" 29 29 nix-compat = { workspace = true } 30 - owo-colors = { version = "4.2.3", features = ["supports-colors"] } 30 + owo-colors = { workspace = true }
+1 -1
wire/cli/src/main.rs
··· 62 62 serde_json::to_string(&hive).into_diagnostic()? 63 63 } else { 64 64 warn!("use --json to output something scripting suitable"); 65 - format!("{hive:#?}") 65 + format!("{hive}") 66 66 } 67 67 }), 68 68 cli::Commands::Completions { shell } => {
+1
wire/lib/Cargo.toml
··· 33 33 aho-corasick = "1.1.3" 34 34 num_enum = "0.7.5" 35 35 gjson = "0.8.1" 36 + owo-colors = { workspace = true } 36 37 37 38 [dev-dependencies] 38 39 tempdir = "0.3"
+71
wire/lib/src/hive/mod.rs
··· 1 1 // SPDX-License-Identifier: AGPL-3.0-or-later 2 2 // Copyright 2024-2025 wire Contributors 3 3 4 + use itertools::Itertools; 4 5 use nix_compat::flakeref::FlakeRef; 5 6 use node::{Name, Node}; 7 + use owo_colors::{OwoColorize, Stream}; 6 8 use serde::de::Error; 7 9 use serde::{Deserialize, Deserializer, Serialize}; 8 10 use std::collections::HashMap; 9 11 use std::collections::hash_map::OccupiedEntry; 10 12 use std::ffi::OsStr; 13 + use std::fmt::Display; 11 14 use std::fs; 12 15 use std::path::PathBuf; 13 16 use std::str::FromStr; ··· 77 80 ))? 78 81 .build_remotely = false; 79 82 } 83 + 84 + Ok(()) 85 + } 86 + } 87 + 88 + impl Display for Hive { 89 + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 90 + for (name, node) in &self.nodes { 91 + writeln!( 92 + f, 93 + "Node {} {}:\n", 94 + name.bold(), 95 + format!("({})", node.host_platform) 96 + .italic() 97 + .if_supports_color(Stream::Stdout, |x| x.dimmed()), 98 + )?; 99 + 100 + if !node.tags.is_empty() { 101 + write!(f, " > {}", "Tags:".bold())?; 102 + writeln!(f, " {:?}", node.tags)?; 103 + } 104 + 105 + write!(f, " > {}", "Connection:".bold())?; 106 + writeln!(f, " {{{}}}", node.target)?; 107 + 108 + write!(f, " > {} {}{}", "Build remotely".bold(), "`deployment.buildOnTarget`".if_supports_color(Stream::Stdout, |x| x.dimmed()).italic(), ":".bold())?; 109 + writeln!(f, " {}", node.build_remotely)?; 110 + 111 + write!(f, " > {} {}{}", "Local apply allowed".bold(), "`deployment.allowLocalDeployment`".if_supports_color(Stream::Stdout, |x| x.dimmed()).italic(), ":".bold())?; 112 + writeln!(f, " {}", node.allow_local_deployment)?; 113 + 114 + if !node.keys.is_empty() { 115 + write!(f, " > {}", "Keys:".bold())?; 116 + writeln!(f, " {} key(s)", node.keys.len())?; 117 + 118 + for key in &node.keys { 119 + writeln!(f, " > {key}")?; 120 + } 121 + } 122 + 123 + writeln!(f)?; 124 + } 125 + 126 + let total_keys = self 127 + .nodes 128 + .values() 129 + .flat_map(|node| node.keys.iter()) 130 + .collect::<Vec<_>>(); 131 + let distinct_keys = self 132 + .nodes 133 + .values() 134 + .flat_map(|node| node.keys.iter()) 135 + .unique() 136 + .collect::<Vec<_>>() 137 + .len(); 138 + 139 + write!(f, "{}", "Summary:".bold())?; 140 + writeln!( 141 + f, 142 + " {} total node(s), totalling {} keys ({distinct_keys} distinct).", 143 + self.nodes.len(), 144 + total_keys.len() 145 + )?; 146 + writeln!( 147 + f, 148 + "{}", 149 + "Note: Listed connections are tried from Left to Right".italic(), 150 + )?; 80 151 81 152 Ok(()) 82 153 }
+14
wire/lib/src/hive/node.rs
··· 170 170 } 171 171 } 172 172 173 + impl Display for Target { 174 + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 175 + let hosts = itertools::Itertools::join( 176 + &mut self 177 + .hosts 178 + .iter() 179 + .map(|host| format!("{}@{host}:{}", self.user, self.port)), 180 + ", ", 181 + ); 182 + 183 + write!(f, "{hosts}") 184 + } 185 + } 186 + 173 187 #[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, Hash)] 174 188 pub struct Node { 175 189 #[serde(rename = "target")]
+24 -5
wire/lib/src/hive/steps/keys.rs
··· 5 5 use base64::prelude::BASE64_STANDARD; 6 6 use futures::future::join_all; 7 7 use itertools::{Itertools, Position}; 8 + use owo_colors::OwoColorize; 8 9 use prost::Message; 9 10 use prost::bytes::BytesMut; 10 11 use serde::{Deserialize, Serialize}; ··· 12 13 use std::env; 13 14 use std::fmt::Display; 14 15 use std::io::Cursor; 15 - use std::path::PathBuf; 16 + use std::path::{PathBuf}; 16 17 use std::pin::Pin; 17 18 use std::process::Stdio; 18 19 use std::str::from_utf8; ··· 62 63 pub environment: im::HashMap<String, String>, 63 64 } 64 65 66 + impl Display for Key { 67 + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 68 + write!( 69 + f, 70 + "{} {} {}:{} {}", 71 + match self.source { 72 + Source::String(_) => "Literal", 73 + Source::Path(_) => "Path", 74 + Source::Command(_) => "Command", 75 + }.if_supports_color(owo_colors::Stream::Stdout, |x| x.dimmed()), 76 + [self.dest_dir.clone(), self.name.clone()] 77 + .iter() 78 + .collect::<PathBuf>() 79 + .display(), 80 + self.user, 81 + self.group, 82 + self.permissions, 83 + ) 84 + } 85 + } 86 + 65 87 fn get_u32_permission(key: &Key) -> Result<u32, KeyError> { 66 88 u32::from_str_radix(&key.permissions, 8).map_err(KeyError::ParseKeyPermissions) 67 89 } ··· 114 136 115 137 let destination: PathBuf = [key.dest_dir.clone(), key.name.clone()].iter().collect(); 116 138 117 - debug!( 118 - "Staging push to {}", 119 - destination.clone().into_os_string().into_string().unwrap() 120 - ); 139 + debug!("Staging push to {}", destination.clone().display()); 121 140 122 141 Ok(( 123 142 key_agent::keys::KeySpec {