From fa309c28497168b61835fe4ac5d37d87a26086b1 Mon Sep 17 00:00:00 2001 From: marshmallow Date: Sat, 22 Nov 2025 16:32:19 +1100 Subject: [PATCH] add typos checker --- CHANGELOG.md | 4 ++-- README.md | 2 +- doc/default.nix | 4 ++-- doc/guides/keys.md | 2 +- doc/guides/targeting.md | 2 +- doc/package.nix | 4 ++-- nix/hooks.nix | 6 ++++++ runtime/module/options.nix | 4 ++-- tests/nix/default.nix | 4 ++-- tests/nix/suite/test_keys/default.nix | 10 +++++----- tests/nix/tools.py | 2 +- typos.toml | 16 ++++++++++++++++ wire/cli/default.nix | 2 +- wire/cli/src/cli.rs | 2 +- wire/cli/src/main.rs | 2 +- wire/lib/build.rs | 10 +++++----- wire/lib/src/commands/pty/mod.rs | 2 +- wire/lib/src/errors.rs | 8 ++++---- wire/lib/src/hive/mod.rs | 16 ++++++++-------- wire/lib/src/hive/steps/keys.rs | 2 +- 20 files changed, 63 insertions(+), 41 deletions(-) create mode 100644 typos.toml diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e9b645..46262d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -111,14 +111,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - There is a new package output, `wire-small`, for testing purposes. It only compiles the key agent for the host that builds `wire-small`. - `--no-progress` now defaults to true if stdin does not refer to a tty (unix pipelines, in CI). -- Added an error for the internal hive evluation parse failure. +- Added an error for the internal hive evaluation parse failure. - The `inspect` command now has `show` as an alias. - Remove `log` command as there are currently no plans to implement the feature - The `completions` command is now hidden from the help page ### Fixed -- A non-existant key owner user/group would not default to gid/uid `0`. +- A non-existent key owner user/group would not default to gid/uid `0`. - Keys can now be deployed to localhost. ## [0.2.0] - 2025-04-21 diff --git a/README.md b/README.md index c246018..50b5af2 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ wire │ ├── cli │ │ └── Rust binary, using `lib` │ └── key_agent -│ └── Rust binary ran on a target node. recieves key file bytes and metadata w/ protobuf over SSH stdin +│ └── Rust binary ran on a target node. receives key file bytes and metadata w/ protobuf over SSH stdin ├── doc │ └── a [vitepress](https://vitepress.dev/) site ├── runtime diff --git a/doc/default.nix b/doc/default.nix index 634b97a..06b8027 100644 --- a/doc/default.nix +++ b/doc/default.nix @@ -9,11 +9,11 @@ packages = { docs = pkgs.callPackage ./package.nix { mode = "stable"; - inherit (self'.packages) wire-small-dev wire-dignostics-md; + inherit (self'.packages) wire-small-dev wire-diagnostics-md; }; docs-unstable = pkgs.callPackage ./package.nix { - inherit (self'.packages) wire-small-dev wire-dignostics-md; + inherit (self'.packages) wire-small-dev wire-diagnostics-md; }; }; }; diff --git a/doc/guides/keys.md b/doc/guides/keys.md index b5cf5f7..8d8c067 100644 --- a/doc/guides/keys.md +++ b/doc/guides/keys.md @@ -23,7 +23,7 @@ work well with wire keys include: ### Prerequisites -wire uses a Rust binary to recieve encrypted key data, so your deploying +wire uses a Rust binary to receive encrypted key data, so your deploying user must be trusted or you must add garnix as a trusted public key: ```nix diff --git a/doc/guides/targeting.md b/doc/guides/targeting.md index 3acfd0d..c80d6b1 100644 --- a/doc/guides/targeting.md +++ b/doc/guides/targeting.md @@ -21,7 +21,7 @@ Will switch-to-configuration on node a, and node b. ## Reading from Stdin -Passing `--on -` will read whitespace-seperated nodes and tags from stdin. This +Passing `--on -` will read whitespace-separated nodes and tags from stdin. This can be combined with normal `--on` usage. For example: diff --git a/doc/package.nix b/doc/package.nix index 83b6a81..c3486c6 100644 --- a/doc/package.nix +++ b/doc/package.nix @@ -3,7 +3,7 @@ nixosOptionsDoc, runCommand, wire-small-dev, - wire-dignostics-md, + wire-diagnostics-md, nix, nodejs, pnpm, @@ -56,7 +56,7 @@ stdenv.mkDerivation (finalAttrs: { }; patchPhase = '' cat ${optionsDoc} >> ./reference/module.md - cat ${wire-dignostics-md} >> ./reference/errors.md + cat ${wire-diagnostics-md} >> ./reference/errors.md wire inspect --markdown-help > ./reference/cli.md ''; buildPhase = "pnpm run build > build.log 2>&1"; diff --git a/nix/hooks.nix b/nix/hooks.nix index 2246855..d6bd192 100644 --- a/nix/hooks.nix +++ b/nix/hooks.nix @@ -31,6 +31,12 @@ name = "nix fmt"; entry = "${lib.getExe config.formatter} --no-cache"; }; + typos = { + enable = true; + settings = { + configPath = "typos.toml"; + }; + }; }; diff --git a/runtime/module/options.nix b/runtime/module/options.nix index 087a7c8..ff4fca6 100644 --- a/runtime/module/options.nix +++ b/runtime/module/options.nix @@ -84,13 +84,13 @@ in replaceUnknownProfiles = lib.mkOption { type = types.bool; - description = "No-op, colmena compatability"; + description = "No-op, colmena compatibility"; default = true; }; sshOptions = lib.mkOption { type = types.listOf types.str; - description = "No-op, colmena compatability"; + description = "No-op, colmena compatibility"; default = [ ]; }; diff --git a/tests/nix/default.nix b/tests/nix/default.nix index 05e0d60..b10cc6b 100644 --- a/tests/nix/default.nix +++ b/tests/nix/default.nix @@ -86,9 +86,9 @@ in let # TODO: Update once #126 is solved. nixPackage = nixpkgs.legacyPackages.lix; - sanitizeName = + sanitiseName = str: lib.strings.sanitizeDerivationName (builtins.replaceStrings [ "." ] [ "_" ] str); - identifier = sanitizeName "${nixpkgs.legacyPackages.lib.trivial.release}-${nixPackage.name}"; + identifier = sanitiseName "${nixpkgs.legacyPackages.lib.trivial.release}-${nixPackage.name}"; path = "tests/nix/suite/${testName}"; flakeDirFileset = lib.fileset.toSource { diff --git a/tests/nix/suite/test_keys/default.nix b/tests/nix/suite/test_keys/default.nix index 93379c7..cf8bff9 100644 --- a/tests/nix/suite/test_keys/default.nix +++ b/tests/nix/suite/test_keys/default.nix @@ -53,7 +53,7 @@ def perform_routine(target, target_object, non_interactive): test_keys(target, target_object, non_interactive) - # only check systemd units on receiver since deployer applys are one time only + # only check systemd units on receiver since deployer apply's are one time only if target == "receiver": target_object.succeed("systemctl start source_string_name-key.path") target_object.succeed("systemctl start command-key.path") @@ -87,10 +87,10 @@ (deployer, new_deployer_store_objects), (receiver, new_receiver_store_objects), ]: - assert_store_not_posioned(node, "hello_world_source", objects) - assert_store_not_posioned(node, "hello_world_file", objects) - assert_store_not_posioned(node, "hello_world_command", objects) - assert_store_not_posioned(node, "string_from_environment", objects) + assert_store_not_poisoned(node, "hello_world_source", objects) + assert_store_not_poisoned(node, "hello_world_file", objects) + assert_store_not_poisoned(node, "hello_world_command", objects) + assert_store_not_poisoned(node, "string_from_environment", objects) ''; }; } diff --git a/tests/nix/tools.py b/tests/nix/tools.py index 1492e37..2e1a563 100644 --- a/tests/nix/tools.py +++ b/tests/nix/tools.py @@ -6,7 +6,7 @@ def collect_store_objects(machine: Machine) -> set[str]: return set(machine.succeed("ls /nix/store").strip().split("\n")) -def assert_store_not_posioned(machine: Machine, poison: str, objects: set[str]): +def assert_store_not_poisoned(machine: Machine, poison: str, objects: set[str]): paths = list(map(lambda n: f"/nix/store/{n}", objects)) machine.succeed("which rg") diff --git a/typos.toml b/typos.toml new file mode 100644 index 0000000..99fbb97 --- /dev/null +++ b/typos.toml @@ -0,0 +1,16 @@ +[files] +extend-exclude = ["COPYING"] + +[default] +locale = "en-au" + +[type.nix] +# nixpkgs +extend-ignore-re = ["authorizedKeys", "sanitizeDerivationName"] + +[type.md] +extend-ignore-re = ["authorizedKeys", "Initialized empty Git"] + +[type.rust.extend-words] +# serde +serialize = "serialize" diff --git a/wire/cli/default.nix b/wire/cli/default.nix index 6ce8191..244402b 100644 --- a/wire/cli/default.nix +++ b/wire/cli/default.nix @@ -81,7 +81,7 @@ paths = [ self'.packages.wire-unwrapped-perf ]; }; - wire-dignostics-md = self'.packages.wire-unwrapped.overrideAttrs { + wire-diagnostics-md = self'.packages.wire-unwrapped.overrideAttrs { DIAGNOSTICS_MD_OUTPUT = "/build/source"; installPhase = '' mv /build/source/DIAGNOSTICS.md $out diff --git a/wire/cli/src/cli.rs b/wire/cli/src/cli.rs index a46b84d..f599918 100644 --- a/wire/cli/src/cli.rs +++ b/wire/cli/src/cli.rs @@ -137,7 +137,7 @@ pub struct ApplyArgs { /// List of literal node names, a literal `-`, or `@` prefixed tags. /// - /// `-` will read additional values from stdin, seperated by whitespace. + /// `-` will read additional values from stdin, separated by whitespace. /// Any `-` implies `--non-interactive`. #[arg(short, long, value_name = "NODE | @TAG | `-`", num_args = 1..)] pub on: Vec, diff --git a/wire/cli/src/main.rs b/wire/cli/src/main.rs index b54a205..59e2456 100644 --- a/wire/cli/src/main.rs +++ b/wire/cli/src/main.rs @@ -44,7 +44,7 @@ async fn main() -> Result<()> { } if !matches!(args.command, cli::Commands::Completions { .. }) && !check_nix_available() { - miette::bail!("Nix is not availabile on this system."); + miette::bail!("Nix is not available on this system."); } let location = get_hive_location(args.path)?; diff --git a/wire/lib/build.rs b/wire/lib/build.rs index f603be8..a2359eb 100644 --- a/wire/lib/build.rs +++ b/wire/lib/build.rs @@ -21,14 +21,14 @@ macro_rules! p { } #[derive(Debug)] -struct DerviedError { +struct DerivedError { code: Option, help: Option, message: Option, doc_string: String, } -impl Display for DerviedError { +impl Display for DerivedError { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!( f, @@ -61,7 +61,7 @@ impl Display for DerviedError { } } -impl DerviedError { +impl DerivedError { fn get_error(&mut self, list: &MetaList) -> Result<(), miette::Error> { if list.path.segments.last().unwrap().ident != "error" { return Err(miette!("Not an error")); @@ -153,12 +153,12 @@ fn main() -> Result<()> { let syntax_tree = parse_file(&src) .into_diagnostic() .wrap_err("parsing errors.rs")?; - let mut entries: Vec = Vec::new(); + let mut entries: Vec = Vec::new(); for item in &syntax_tree.items { if let Item::Enum(ItemEnum { variants, .. }) = item { for variant in variants { - let mut entry = DerviedError { + let mut entry = DerivedError { code: None, help: None, message: None, diff --git a/wire/lib/src/commands/pty/mod.rs b/wire/lib/src/commands/pty/mod.rs index 20b2e84..68bf3dc 100644 --- a/wire/lib/src/commands/pty/mod.rs +++ b/wire/lib/src/commands/pty/mod.rs @@ -307,7 +307,7 @@ fn build_command>( let mut command = if let Some(target) = arguments.target { let mut command = create_int_ssh_command(target, arguments.modifiers)?; - // force ssh to use our pesudo terminal + // force ssh to use our pseudo terminal command.arg("-tt"); command diff --git a/wire/lib/src/errors.rs b/wire/lib/src/errors.rs index 766855f..7f3aa13 100644 --- a/wire/lib/src/errors.rs +++ b/wire/lib/src/errors.rs @@ -121,7 +121,7 @@ pub enum NetworkError { } #[derive(Debug, Diagnostic, Error)] -pub enum HiveInitializationError { +pub enum HiveInitialisationError { #[diagnostic( code(wire::hive_init::NoHiveFound), help( @@ -213,7 +213,7 @@ pub enum CommandError { WaitForStatus(#[source] std::io::Error), #[diagnostic( - code(wire::detatched::NoHandle), + code(wire::detached::NoHandle), help("This should never happen, please create an issue!"), url("{DOCS_URL}#{}", self.code().unwrap()) )] @@ -247,7 +247,7 @@ pub enum CommandError { url("{DOCS_URL}#{}", self.code().unwrap()), help("please create an issue!"), )] - #[error("Thread paniced")] + #[error("Thread panicked")] ThreadPanic, #[diagnostic( @@ -289,7 +289,7 @@ pub enum CommandError { pub enum HiveLibError { #[error(transparent)] #[diagnostic(transparent)] - HiveInitializationError(HiveInitializationError), + HiveInitialisationError(HiveInitialisationError), #[error(transparent)] #[diagnostic(transparent)] diff --git a/wire/lib/src/hive/mod.rs b/wire/lib/src/hive/mod.rs index ae639cc..e323f84 100644 --- a/wire/lib/src/hive/mod.rs +++ b/wire/lib/src/hive/mod.rs @@ -18,7 +18,7 @@ use std::sync::Arc; use tracing::{info, instrument}; use crate::commands::common::evaluate_hive_attribute; -use crate::errors::{HiveInitializationError, HiveLocationError}; +use crate::errors::{HiveInitialisationError, HiveLocationError}; use crate::{EvalGoal, HiveLibError, SubCommandModifiers}; pub mod node; pub mod steps; @@ -60,7 +60,7 @@ impl Hive { let output = evaluate_hive_attribute(location, &EvalGoal::Inspect, modifiers).await?; let hive: Hive = serde_json::from_str(&output).map_err(|err| { - HiveLibError::HiveInitializationError(HiveInitializationError::ParseEvaluateError(err)) + HiveLibError::HiveInitialisationError(HiveInitialisationError::ParseEvaluateError(err)) })?; Ok(hive) @@ -75,8 +75,8 @@ impl Hive { self.nodes .get_mut(&Name(Arc::from(node.clone()))) - .ok_or(HiveLibError::HiveInitializationError( - HiveInitializationError::NodeDoesNotExist(node.clone()), + .ok_or(HiveLibError::HiveInitialisationError( + HiveInitialisationError::NodeDoesNotExist(node.clone()), ))? .build_remotely = false; } @@ -371,10 +371,10 @@ mod tests { .unwrap(); assert_matches!( - hive.force_always_local(vec!["non-existant".to_string()]), - Err(HiveLibError::HiveInitializationError( - HiveInitializationError::NodeDoesNotExist(node) - )) if node == "non-existant" + hive.force_always_local(vec!["non-existent".to_string()]), + Err(HiveLibError::HiveInitialisationError( + HiveInitialisationError::NodeDoesNotExist(node) + )) if node == "non-existent" ); for node in hive.nodes.values() { diff --git a/wire/lib/src/hive/steps/keys.rs b/wire/lib/src/hive/steps/keys.rs index eb7f619..ef0654f 100644 --- a/wire/lib/src/hive/steps/keys.rs +++ b/wire/lib/src/hive/steps/keys.rs @@ -144,7 +144,7 @@ async fn process_key(key: &Key) -> Result<(key_agent::keys::KeySpec, Vec), K length: buf .len() .try_into() - .expect("Failed to conver usize buf length to i32"), + .expect("Failed to convert usize buf length to i32"), user: key.user.clone(), group: key.group.clone(), permissions: get_u32_permission(key)?, -- 2.51.2