diff --git a/cli/src/config.rs b/cli/src/config.rs index 26a5a94..305bbda 100644 --- a/cli/src/config.rs +++ b/cli/src/config.rs @@ -15,17 +15,11 @@ pub struct Entry { impl Entry { pub fn fetch(&self) -> (String, Vec) { - let mut stream: Vec<_> = self.keys - .par_iter() - .map(|k| k.fetch()) - .flatten() - .collect(); + let mut stream: Vec<_> = self.keys.par_iter().map(|k| k.fetch()).flatten().collect(); // Deduplicate keys, no need for duplicated entries stream.sort(); - stream.dedup_by(|a, b| { - a.key_data() == b.key_data() - }); + stream.dedup_by(|a, b| a.key_data() == b.key_data()); (self.name.clone(), stream) } @@ -39,10 +33,7 @@ pub struct Config { impl Config { pub fn fetch(&self) -> Result { - let keys = self.entries - .par_iter() - .map(Entry::fetch) - .collect(); + let keys = self.entries.par_iter().map(Entry::fetch).collect(); Ok(Output { keys }) } diff --git a/cli/src/main.rs b/cli/src/main.rs index a10050b..e88c0e7 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -2,11 +2,11 @@ // // SPDX-License-Identifier: EUPL-1.2 -use simple_eyre::eyre::Result; use clap::Parser; -use std::path::Path; +use simple_eyre::eyre::Result; use std::fs::File; use std::io::{self, prelude::*}; +use std::path::Path; #[derive(Debug, Clone)] enum Input { diff --git a/cli/src/output/mod.rs b/cli/src/output/mod.rs index e228340..70ae75a 100644 --- a/cli/src/output/mod.rs +++ b/cli/src/output/mod.rs @@ -42,7 +42,7 @@ impl<'a> From<&'a str> for Format { "json-pretty" => Format::JSONPretty, "toml" => Format::TOML, "toml-pretty" => Format::TOMLPretty, - _ => unreachable!() + _ => unreachable!(), } } } diff --git a/cli/src/sources/atproto.rs b/cli/src/sources/atproto.rs index a543145..9e81284 100644 --- a/cli/src/sources/atproto.rs +++ b/cli/src/sources/atproto.rs @@ -196,7 +196,12 @@ impl super::Fetch for ATProto { url.set_path("xrpc/com.atproto.repo.listRecords"); - let data = ureq::get(&url.to_string()).call().unwrap().body_mut().read_to_string().unwrap(); + let data = ureq::get(&url.to_string()) + .call() + .unwrap() + .body_mut() + .read_to_string() + .unwrap(); let decoded: resp::Resp = serde_json::from_str(&data).unwrap(); diff --git a/cli/src/sources/helpers.rs b/cli/src/sources/helpers.rs index f54ddc9..6684b5a 100644 --- a/cli/src/sources/helpers.rs +++ b/cli/src/sources/helpers.rs @@ -2,8 +2,8 @@ // // SPDX-License-Identifier: EUPL-1.2 -use std::str::FromStr; use std::fmt; +use std::str::FromStr; use serde::{de, Deserialize, Deserializer}; diff --git a/cli/src/sources/mod.rs b/cli/src/sources/mod.rs index ad78729..426055e 100644 --- a/cli/src/sources/mod.rs +++ b/cli/src/sources/mod.rs @@ -37,30 +37,22 @@ impl Fetch for Source { Source::Raw(ref raw) => raw.fetch(), Source::Hosts(ref raw) => raw.fetch(), Source::Http(ref raw) => raw.fetch(), - Source::Github(ref user) => { - Http { - url: format!("https://github.com/{user}.keys"), - } - .fetch() + Source::Github(ref user) => Http { + url: format!("https://github.com/{user}.keys"), } - Source::Sourcehut(ref user) => { - Http { - url: format!("https://meta.sr.ht/{user}.keys"), - } - .fetch() + .fetch(), + Source::Sourcehut(ref user) => Http { + url: format!("https://meta.sr.ht/{user}.keys"), } - Source::Gitlab(ref user) => { - Http { - url: format!("https://gitlab.com/{user}.keys"), - } - .fetch() + .fetch(), + Source::Gitlab(ref user) => Http { + url: format!("https://gitlab.com/{user}.keys"), } - Source::Codeberg(ref user) => { - Http { - url: format!("https://codeberg.org/{user}.keys"), - } - .fetch() + .fetch(), + Source::Codeberg(ref user) => Http { + url: format!("https://codeberg.org/{user}.keys"), } + .fetch(), Source::Tangled(ref atproto) => atproto.fetch(), } } @@ -81,10 +73,7 @@ pub struct Hosts(pub Box<[String]>); impl Fetch for Hosts { fn fetch(&self) -> Vec { // TODO: Check if we can do it in-process instead of shelling out to `ssh-keyscan` - let result = Command::new("ssh-keyscan") - .args(&self.0) - .output() - .unwrap(); + let result = Command::new("ssh-keyscan").args(&self.0).output().unwrap(); std::str::from_utf8(&result.stdout) .unwrap() @@ -93,15 +82,9 @@ impl Fetch for Hosts { .map(str::trim) // Remove comments .filter(|line| !line.starts_with("#")) - .map(|line| { - // Ignore first column as it contain hostname which is not - // needed there - line.split(' ') - .skip(1) - .collect::>() - .join(" ") - .to_owned() - }) + // Ignore first column as it contain hostname which is not + // needed there + .map(|line| line.split_once(' ').unwrap().1) .map(|k| PublicKey::from_openssh(&k).unwrap()) .collect() } diff --git a/flake.lock b/flake.lock index 57c79d0..78202dd 100644 --- a/flake.lock +++ b/flake.lock @@ -37,11 +37,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1744588088, - "narHash": "sha256-jymEVhRPzvzVP8XrXJcnVFUmle/FKLZIfSq+9EiobQE=", + "lastModified": 1744815543, + "narHash": "sha256-ybqhaIuv8OU0f14Rr+1ilxE4iTCnguXi/60g4ys6JOI=", "owner": "cachix", "repo": "devenv", - "rev": "1e6c06a058dae3791c0303eb99636cee9605c8d9", + "rev": "2e0e691414835585eeddd1e4e740b45b362052cc", "type": "github" }, "original": { @@ -267,14 +267,18 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 0, - "narHash": "sha256-bWSjxDwq7iVePrhmA7tY2dyMWHuNJo8knkO4y+q4ZkY=", - "path": "/nix/store/5r0zii3rap2dyfyip31pdf9f0hpvv3d7-source", - "type": "path" + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", + "type": "github" }, "original": { - "id": "nixpkgs", - "type": "indirect" + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" } }, "root": { diff --git a/flake.nix b/flake.nix index a4067da..19e73fe 100644 --- a/flake.nix +++ b/flake.nix @@ -7,7 +7,7 @@ inputs = { flake-parts.url = "github:hercules-ci/flake-parts"; - nixpkgs.url = "flake:nixpkgs"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; devenv.url = "github:cachix/devenv"; }; @@ -42,7 +42,9 @@ }; devenv.shells.default = { - languages.rust.enable = true; + languages.rust = { + enable = true; + }; packages = [ diff --git a/xtask/src/main.rs b/xtask/src/main.rs index e4f2953..e182694 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -16,7 +16,9 @@ fn main() -> simple_eyre::Result<()> { let entry = entry?; let file_name = entry.file_name(); let file_name = Path::new(&file_name); - if file_name.extension() != Some(std::ffi::OsStr::new("scd")) { continue } + if file_name.extension() != Some(std::ffi::OsStr::new("scd")) { + continue; + } let outname = Path::file_stem(file_name).unwrap(); let page = Path::new(outname).extension().unwrap().to_str().unwrap();