difftreelog
build update to nixos release-25.05
in: trunk
34 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
-version = 3
+version = 4
[[package]]
name = "abort-on-drop"
@@ -377,29 +377,6 @@
]
[[package]]
-name = "bindgen"
-version = "0.69.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088"
-dependencies = [
- "bitflags",
- "cexpr",
- "clang-sys",
- "itertools 0.12.1",
- "lazy_static",
- "lazycell",
- "log",
- "prettyplease",
- "proc-macro2",
- "quote",
- "regex",
- "rustc-hash",
- "shlex",
- "syn",
- "which",
-]
-
-[[package]]
name = "bitflags"
version = "2.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -488,15 +465,6 @@
]
[[package]]
-name = "cexpr"
-version = "0.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
-dependencies = [
- "nom 7.1.3",
-]
-
-[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -556,17 +524,6 @@
"crypto-common",
"inout",
"zeroize",
-]
-
-[[package]]
-name = "clang-sys"
-version = "1.8.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
-dependencies = [
- "glob",
- "libc",
- "libloading",
]
[[package]]
@@ -1242,12 +1199,6 @@
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
-
-[[package]]
-name = "glob"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "h2"
@@ -1332,15 +1283,6 @@
checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
dependencies = [
"digest",
-]
-
-[[package]]
-name = "home"
-version = "0.5.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
-dependencies = [
- "windows-sys 0.52.0",
]
[[package]]
@@ -1648,15 +1590,6 @@
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
-
-[[package]]
-name = "itertools"
-version = "0.12.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
-dependencies = [
- "either",
-]
[[package]]
name = "itertools"
@@ -1701,28 +1634,12 @@
]
[[package]]
-name = "lazycell"
-version = "1.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
-
-[[package]]
name = "libc"
version = "0.2.174"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
[[package]]
-name = "libloading"
-version = "0.8.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
-dependencies = [
- "cfg-if",
- "windows-targets",
-]
-
-[[package]]
name = "libm"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1887,14 +1804,6 @@
"tokio-util",
"tracing",
"unindent",
-]
-
-[[package]]
-name = "nix-native-eval"
-version = "0.1.0"
-dependencies = [
- "anyhow",
- "nixrs",
]
[[package]]
@@ -1912,25 +1821,6 @@
]
[[package]]
-name = "nixrs"
-version = "0.1.0"
-source = "git+https://github.com/Anillc/nixrs#740fcf4048cc5b6de8c54d18254f12d53909a867"
-dependencies = [
- "libc",
- "nixrs-sys",
- "thiserror 1.0.69",
-]
-
-[[package]]
-name = "nixrs-sys"
-version = "0.1.0"
-source = "git+https://github.com/Anillc/nixrs#740fcf4048cc5b6de8c54d18254f12d53909a867"
-dependencies = [
- "bindgen",
- "pkg-config",
-]
-
-[[package]]
name = "nom"
version = "7.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2224,12 +2114,6 @@
"der",
"spki",
]
-
-[[package]]
-name = "pkg-config"
-version = "0.3.31"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
[[package]]
name = "poly1305"
@@ -3752,18 +3636,6 @@
dependencies = [
"js-sys",
"wasm-bindgen",
-]
-
-[[package]]
-name = "which"
-version = "4.4.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
-dependencies = [
- "either",
- "home",
- "once_cell",
- "rustix 0.38.40",
]
[[package]]
Cargo.tomldiffbeforeafterboth--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,8 +2,8 @@
members = ["crates/*", "cmds/*"]
resolver = "2"
package.version = "0.1.0"
-package.edition = "2021"
-package.rust-version = "1.82.0"
+package.edition = "2024"
+package.rust-version = "1.86.0"
[workspace.dependencies]
better-command = { path = "./crates/better-command" }
cmds/fleet/src/cmds/build_systems.rsdiffbeforeafterboth--- a/cmds/fleet/src/cmds/build_systems.rs
+++ b/cmds/fleet/src/cmds/build_systems.rs
@@ -1,15 +1,15 @@
use std::{env::current_dir, os::unix::fs::symlink, path::PathBuf};
-use anyhow::{anyhow, Result};
+use anyhow::{Result, anyhow};
use clap::Parser;
use fleet_base::{
- deploy::{deploy_task, upload_task, DeployAction},
+ deploy::{DeployAction, deploy_task, upload_task},
host::{Config, DeployKind, GenerationStorage},
opts::FleetOpts,
};
-use nix_eval::{nix_go, NixBuildBatch};
+use nix_eval::{NixBuildBatch, nix_go};
use tokio::task::LocalSet;
-use tracing::{error, field, info, info_span, warn, Instrument};
+use tracing::{Instrument, error, field, info, info_span, warn};
#[derive(Parser)]
pub struct Deploy {
@@ -167,11 +167,12 @@
self.action,
&host,
remote_path,
- if let Ok(v) = opts.action_attr(&host, "specialisation").await {
- v
- } else {
- error!("unreachable? failed to get specialization");
- return;
+ match opts.action_attr(&host, "specialisation").await {
+ Ok(v) => v,
+ _ => {
+ error!("unreachable? failed to get specialization");
+ return;
+ }
},
disable_rollback,
)
cmds/fleet/src/cmds/info.rsdiffbeforeafterboth--- a/cmds/fleet/src/cmds/info.rs
+++ b/cmds/fleet/src/cmds/info.rs
@@ -1,6 +1,6 @@
use std::collections::BTreeSet;
-use anyhow::{ensure, Result};
+use anyhow::{Result, ensure};
use clap::Parser;
use fleet_base::host::Config;
use nix_eval::nix_go_json;
cmds/fleet/src/cmds/mod.rsdiffbeforeafterboth--- a/cmds/fleet/src/cmds/mod.rs
+++ b/cmds/fleet/src/cmds/mod.rs
@@ -1,6 +1,6 @@
pub mod build_systems;
pub mod complete;
pub mod info;
+pub mod rollback;
pub mod secrets;
pub mod tf;
-pub mod rollback;
\ No newline at end of file
cmds/fleet/src/cmds/rollback.rsdiffbeforeafterboth--- a/cmds/fleet/src/cmds/rollback.rs
+++ b/cmds/fleet/src/cmds/rollback.rs
@@ -1,9 +1,9 @@
use std::collections::HashSet;
-use anyhow::{bail, Result};
+use anyhow::{Result, bail};
use clap::Parser;
use fleet_base::{
- deploy::{deploy_task, upload_task, DeployAction},
+ deploy::{DeployAction, deploy_task, upload_task},
host::{Config, ConfigHost, Generation, GenerationStorage},
opts::FleetOpts,
};
cmds/fleet/src/cmds/secrets/mod.rsdiffbeforeafterboth--- a/cmds/fleet/src/cmds/secrets/mod.rs
+++ b/cmds/fleet/src/cmds/secrets/mod.rs
@@ -1,25 +1,25 @@
use std::{
collections::{BTreeMap, BTreeSet, HashSet},
- io::{self, stdin, stdout, Read, Write},
+ io::{self, Read, Write, stdin, stdout},
path::PathBuf,
};
use age::Recipient;
-use anyhow::{anyhow, bail, ensure, Context, Result};
+use anyhow::{Context, Result, anyhow, bail, ensure};
use chrono::{DateTime, Utc};
use clap::Parser;
use fleet_base::{
- fleetdata::{encrypt_secret_data, FleetSecret, FleetSecretPart, FleetSharedSecret},
+ fleetdata::{FleetSecret, FleetSecretPart, FleetSharedSecret, encrypt_secret_data},
host::Config,
opts::FleetOpts,
};
use fleet_shared::SecretData;
-use nix_eval::{nix_go, nix_go_json, NixBuildBatch, Value};
+use nix_eval::{NixBuildBatch, Value, nix_go, nix_go_json};
use owo_colors::OwoColorize;
use serde::Deserialize;
use tabled::{Table, Tabled};
use tokio::fs::read;
-use tracing::{error, info, info_span, warn, Instrument};
+use tracing::{Instrument, error, info, info_span, warn};
#[derive(Parser)]
pub enum Secret {
@@ -187,7 +187,9 @@
true
} else if set.difference(&expected_set).next().is_some() {
// TODO: Remove this warning for revokable secrets.
- warn!("host was removed from secret owners, but until this host rebuild, the secret will still be stored on it.");
+ warn!(
+ "host was removed from secret owners, but until this host rebuild, the secret will still be stored on it."
+ );
nix_go_json!(field.regenerateOnOwnerRemoved)
} else if expected_set.difference(&set).next().is_some() {
nix_go_json!(field.regenerateOnOwnerAdded)
@@ -296,8 +298,8 @@
let out_parent = host.mktemp_dir().await?;
let out = format!("{out_parent}/out");
- let mut gen = host.cmd(generator).await?;
- gen.env("out", &out);
+ let mut r#gen = host.cmd(generator).await?;
+ r#gen.env("out", &out);
if on.is_none() {
// This path is local, thus we can feed `OsString` directly to env var... But I don't think that's necessary to handle.
let project_path: String = config
@@ -306,9 +308,9 @@
.into_os_string()
.into_string()
.map_err(|s| anyhow!("fleet project path is not utf-8: {s:?}"))?;
- gen.env("FLEET_PROJECT", project_path);
+ r#gen.env("FLEET_PROJECT", project_path);
}
- gen.run().await.context("impure generator")?;
+ r#gen.run().await.context("impure generator")?;
{
let marker = host.read_file_text(format!("{out}/marker")).await?;
@@ -510,7 +512,9 @@
if !remove_machines.is_empty() {
// TODO: maybe force secret regeneration?
// Not that useful without revokation.
- warn!("secret will not be regenerated for removed machines, and until host rebuild, they will still possess the ability to decode secret");
+ warn!(
+ "secret will not be regenerated for removed machines, and until host rebuild, they will still possess the ability to decode secret"
+ );
}
Ok(target_machines)
}
@@ -596,7 +600,9 @@
part: part_name,
} => {
if config.has_secret(&machine, &name) && !replace && !merge {
- bail!("secret already defined.\nUse --replace to override, or --merge to add new parts to existing secret");
+ bail!(
+ "secret already defined.\nUse --replace to override, or --merge to add new parts to existing secret"
+ );
}
let mut out = if merge && !replace {
cmds/fleet/src/extra_args.rsdiffbeforeafterboth--- a/cmds/fleet/src/extra_args.rs
+++ b/cmds/fleet/src/extra_args.rs
@@ -1,6 +1,6 @@
use std::ffi::{OsStr, OsString};
-use anyhow::{anyhow, Result};
+use anyhow::{Result, anyhow};
pub fn parse_os(os: &OsStr) -> Result<Vec<OsString>> {
Ok(shlex::bytes::split(os.as_encoded_bytes())
cmds/fleet/src/main.rsdiffbeforeafterboth--- a/cmds/fleet/src/main.rs
+++ b/cmds/fleet/src/main.rs
@@ -6,27 +6,27 @@
use std::{ffi::OsString, process::ExitCode};
-use anyhow::{bail, Result};
+use anyhow::{Result, bail};
use clap::{CommandFactory, Parser};
use cmds::{
build_systems::{BuildSystems, Deploy},
- rollback::RollbackSingle,
complete::Complete,
info::Info,
+ rollback::RollbackSingle,
secrets::Secret,
tf::Tf,
};
use fleet_base::{host::Config, opts::FleetOpts};
-use futures::{future::LocalBoxFuture, stream::FuturesUnordered, TryStreamExt};
+use futures::{TryStreamExt, future::LocalBoxFuture, stream::FuturesUnordered};
// use host::Config;
#[cfg(feature = "indicatif")]
use human_repr::HumanCount;
#[cfg(feature = "indicatif")]
use indicatif::{ProgressState, ProgressStyle};
-use tracing::{error, info, info_span, Instrument};
+use tracing::{Instrument, error, info, info_span};
#[cfg(feature = "indicatif")]
use tracing_indicatif::IndicatifLayer;
-use tracing_subscriber::{prelude::*, EnvFilter};
+use tracing_subscriber::{EnvFilter, prelude::*};
#[derive(Parser)]
struct Prefetch {}
cmds/generator-helper/src/main.rsdiffbeforeafterboth--- a/cmds/generator-helper/src/main.rs
+++ b/cmds/generator-helper/src/main.rs
@@ -1,21 +1,22 @@
use std::{
env,
fs::{File, OpenOptions},
- io::{self, copy, stdin, stdout, Read, Write},
+ io::{self, Read, Write, copy, stdin, stdout},
str::FromStr,
};
use age::{
+ Encryptor, Recipient,
ssh::{ParseRecipientKeyError, Recipient as SshRecipient},
- Encryptor, Recipient,
};
-use anyhow::{anyhow, bail, ensure, Context, Result};
+use anyhow::{Context, Result, anyhow, bail, ensure};
use clap::{Parser, ValueEnum};
use ed25519_dalek::SecretKey;
use fleet_shared::SecretData;
use rand::{
+ RngCore,
distr::{Alphanumeric, Distribution, SampleString, Uniform},
- rng, RngCore,
+ rng,
};
fn write_output_file(out: &str) -> Result<File> {
@@ -78,7 +79,9 @@
let list = match list {
Ok(v) => v,
Err(env::VarError::NotPresent) => {
- bail!("gh is only intended to be used from secret generator scripts, but if you really want to use it somewhere else - set GENERATOR_HELPER_IDENTITIES to list of newline-delimited ssh identities");
+ bail!(
+ "gh is only intended to be used from secret generator scripts, but if you really want to use it somewhere else - set GENERATOR_HELPER_IDENTITIES to list of newline-delimited ssh identities"
+ );
}
Err(e) => bail!("somehow, identities list is not utf-8: {e}"),
};
@@ -254,13 +257,7 @@
write_private(
&recipients,
&private,
- &key[..{
- if no_embed_public {
- 32
- } else {
- 64
- }
- }],
+ &key[..{ if no_embed_public { 32 } else { 64 } }],
encoding,
)?;
}
cmds/install-secrets/src/main.rsdiffbeforeafterboth--- a/cmds/install-secrets/src/main.rs
+++ b/cmds/install-secrets/src/main.rs
@@ -5,20 +5,20 @@
iter,
os::unix::prelude::PermissionsExt,
path::{Path, PathBuf},
- str::{from_utf8, FromStr},
+ str::{FromStr, from_utf8},
};
use age::{
- ssh::{Identity as SshIdentity, Recipient as SshRecipient},
Decryptor, Encryptor, Identity, Recipient,
+ ssh::{Identity as SshIdentity, Recipient as SshRecipient},
};
-use anyhow::{anyhow, bail, ensure, Context, Result};
+use anyhow::{Context, Result, anyhow, bail, ensure};
use clap::Parser;
use fleet_shared::SecretData;
-use nix::unistd::{chown, Group, User};
+use nix::unistd::{Group, User, chown};
use serde::Deserialize;
use tracing::{error, info, info_span};
-use tracing_subscriber::{filter::LevelFilter, EnvFilter};
+use tracing_subscriber::{EnvFilter, filter::LevelFilter};
#[derive(Parser)]
#[clap(author)]
cmds/terraform-provider-fleet/src/main.rsdiffbeforeafterboth--- a/cmds/terraform-provider-fleet/src/main.rs
+++ b/cmds/terraform-provider-fleet/src/main.rs
@@ -1,3 +1,5 @@
fn main() {
- panic!("this is a stub, real provider is in development, I just don't want to keep it in different branch.")
+ panic!(
+ "this is a stub, real provider is in development, I just don't want to keep it in different branch."
+ )
}
crates/better-command/src/handler.rsdiffbeforeafterboth--- a/crates/better-command/src/handler.rs
+++ b/crates/better-command/src/handler.rs
@@ -7,7 +7,7 @@
use regex::Regex;
use serde::Deserialize;
-use tracing::{info, info_span, warn, Span};
+use tracing::{Span, info, info_span, warn};
#[cfg(feature = "indicatif")]
use tracing_indicatif::span_ext::IndicatifSpanExt as _;
@@ -112,9 +112,13 @@
match log {
NixLog::Msg { msg, raw_msg, .. } => {
#[allow(clippy::nonminimal_bool)]
- if !(msg.starts_with("\u{1b}[35;1mwarning:\u{1b}[0m Git tree '") && msg.ends_with("' is dirty"))
- && !msg.starts_with("\u{1b}[35;1mwarning:\u{1b}[0m not writing modified lock file of flake")
- && msg != "\u{1b}[35;1mwarning:\u{1b}[0m \u{1b}[31;1merror:\u{1b}[0m SQLite database '\u{1b}[35;1m/nix/var/nix/db/db.sqlite\u{1b}[0m' is busy" {
+ if !(msg.starts_with("\u{1b}[35;1mwarning:\u{1b}[0m Git tree '")
+ && msg.ends_with("' is dirty"))
+ && !msg.starts_with(
+ "\u{1b}[35;1mwarning:\u{1b}[0m not writing modified lock file of flake",
+ ) && msg
+ != "\u{1b}[35;1mwarning:\u{1b}[0m \u{1b}[31;1merror:\u{1b}[0m SQLite database '\u{1b}[35;1m/nix/var/nix/db/db.sqlite\u{1b}[0m' is busy"
+ {
if let Some(raw_msg) = raw_msg {
if !msg.is_empty() {
info!(target: "nix", "{}\n{}", raw_msg.trim_end(), msg.trim_end())
@@ -156,8 +160,12 @@
id,
..
} if typ == 100 && fields.len() >= 3 => {
- if let [LogField::String(drv), LogField::String(from), LogField::String(to), ..] =
- &fields[..]
+ if let [
+ LogField::String(drv),
+ LogField::String(from),
+ LogField::String(to),
+ ..,
+ ] = &fields[..]
{
let mut drv = drv.as_str();
@@ -289,8 +297,12 @@
}
NixLog::Result { fields, id, typ } if typ == 105 && fields.len() >= 4 => {
if let Some(span) = self.spans.get(&id) {
- if let [LogField::Num(done), LogField::Num(expected), LogField::Num(_running), LogField::Num(_failed)] =
- &fields[..4]
+ if let [
+ LogField::Num(done),
+ LogField::Num(expected),
+ LogField::Num(_running),
+ LogField::Num(_failed),
+ ] = &fields[..4]
{
#[cfg(feature = "indicatif")]
{
crates/fleet-base/src/command.rsdiffbeforeafterboth--- a/crates/fleet-base/src/command.rs
+++ b/crates/fleet-base/src/command.rs
@@ -1,6 +1,6 @@
use std::{ffi::OsStr, pin, process::Stdio, sync::Arc, task::Poll};
-use anyhow::{anyhow, Result};
+use anyhow::{Result, anyhow};
use better_command::{Handler, NixHandler, PlainHandler};
use futures::StreamExt;
use itertools::Either;
@@ -68,10 +68,9 @@
}
}
fn new_here(&self, cmd: impl AsRef<OsStr>) -> Self {
- if let Some(ssh_session) = self.ssh_session.clone() {
- Self::new_on(self.escalation, cmd, ssh_session)
- } else {
- Self::new(self.escalation, cmd)
+ match self.ssh_session.clone() {
+ Some(ssh_session) => Self::new_on(self.escalation, cmd, ssh_session),
+ _ => Self::new(self.escalation, cmd),
}
}
@@ -139,15 +138,18 @@
out
}
fn into_command(self) -> Result<Either<Command, openssh::OwningCommand<Arc<Session>>>> {
- Ok(if let Some(session) = self.ssh_session.clone() {
- let cmd = self.translate_env_into_env().into_command_unchecked_local();
- Either::Right(
- cmd.over_ssh(session)
- .map_err(|e| anyhow!("ssh error: {e}"))?,
- )
- } else {
- let cmd = self.into_command_unchecked_local();
- Either::Left(cmd)
+ Ok(match self.ssh_session.clone() {
+ Some(session) => {
+ let cmd = self.translate_env_into_env().into_command_unchecked_local();
+ Either::Right(
+ cmd.over_ssh(session)
+ .map_err(|e| anyhow!("ssh error: {e}"))?,
+ )
+ }
+ _ => {
+ let cmd = self.into_command_unchecked_local();
+ Either::Left(cmd)
+ }
})
}
pub fn arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
crates/fleet-base/src/deploy.rsdiffbeforeafterboth--- a/crates/fleet-base/src/deploy.rs
+++ b/crates/fleet-base/src/deploy.rs
@@ -1,10 +1,10 @@
use std::{path::PathBuf, time::Duration};
-use anyhow::{anyhow, bail, Context as _, Result};
+use anyhow::{Context as _, Result, anyhow, bail};
use clap::ValueEnum;
use itertools::Itertools;
use tokio::time::sleep;
-use tracing::{error, info, info_span, warn, Instrument as _};
+use tracing::{Instrument as _, error, info, info_span, warn};
use crate::host::{Config, ConfigHost, DeployKind, Generation, GenerationStorage};
@@ -221,7 +221,9 @@
.in_current_span()
.await
{
- error!("failed to remove rollback marker. This is bad, as the system will be rolled back by watchdog: {e}")
+ error!(
+ "failed to remove rollback marker. This is bad, as the system will be rolled back by watchdog: {e}"
+ )
}
}
info!("disarming watchdog, just in case");
@@ -233,12 +235,17 @@
error!("failed to disarm rollback run: {e}");
}
}
- } else if let Err(_e) = host
- .rm_file("/etc/fleet_rollback_marker", true)
- .in_current_span()
- .await
- {
- // Marker might not exist, yet better try to remove it.
+ } else {
+ match host
+ .rm_file("/etc/fleet_rollback_marker", true)
+ .in_current_span()
+ .await
+ {
+ Err(_e) => {
+ // Marker might not exist, yet better try to remove it.
+ }
+ _ => {}
+ }
}
}
Ok(())
crates/fleet-base/src/fleetdata.rsdiffbeforeafterboth--- a/crates/fleet-base/src/fleetdata.rs
+++ b/crates/fleet-base/src/fleetdata.rs
@@ -10,7 +10,7 @@
distr::{Alphanumeric, SampleString as _},
rng,
};
-use serde::{de::Error, Deserialize, Serialize};
+use serde::{Deserialize, Serialize, de::Error};
use serde_json::Value;
#[derive(Serialize, Deserialize, Default)]
crates/fleet-base/src/host.rsdiffbeforeafterboth--- a/crates/fleet-base/src/host.rs
+++ b/crates/fleet-base/src/host.rs
@@ -10,14 +10,14 @@
sync::{Arc, Mutex, MutexGuard, OnceLock},
};
-use anyhow::{anyhow, bail, ensure, Context, Result};
+use anyhow::{Context, Result, anyhow, bail, ensure};
use fleet_shared::SecretData;
-use nix_eval::{nix_go, nix_go_json, util::assert_warn, NixSession, Value};
+use nix_eval::{NixSession, Value, nix_go, nix_go_json, util::assert_warn};
use openssh::SessionBuilder;
use serde::de::DeserializeOwned;
use tabled::Tabled;
use tempfile::NamedTempFile;
-use time::{format_description, UtcDateTime};
+use time::{UtcDateTime, format_description};
use tracing::warn;
use crate::{
@@ -87,7 +87,9 @@
"fleet" => Ok(Self::Fleet),
"nixos-install" => Ok(Self::NixosInstall),
"nixos-lustrate" => Ok(Self::NixosLustrate),
- v => bail!("unknown deploy_kind: {v}; expected on of \"upgrade-to-fleet\", \"fleet\", \"nixos-install\", \"nixos-lustrate\""),
+ v => bail!(
+ "unknown deploy_kind: {v}; expected on of \"upgrade-to-fleet\", \"fleet\", \"nixos-install\", \"nixos-lustrate\""
+ ),
}
}
}
@@ -189,11 +191,11 @@
.map(|e| e.trim())
.filter(|&l| !l.is_empty())
.filter_map(|g| {
- let gen = parse_generation_line(g);
- if gen.is_none() {
+ let generation = parse_generation_line(g);
+ if generation.is_none() {
warn!("bad generation: {g}");
};
- gen
+ generation
})
.collect::<Vec<_>>();
for ele in generations.iter_mut() {
crates/fleet-base/src/keys.rsdiffbeforeafterboth--- a/crates/fleet-base/src/keys.rs
+++ b/crates/fleet-base/src/keys.rs
@@ -1,7 +1,7 @@
use std::str::FromStr as _;
use age::Recipient;
-use anyhow::{anyhow, Result};
+use anyhow::{Result, anyhow};
use futures::{StreamExt as _, TryStreamExt as _};
use itertools::Itertools as _;
use tracing::warn;
@@ -39,12 +39,12 @@
}
}
/// Insecure, requires root
- pub async fn recipient(&self, host: &str) -> anyhow::Result<impl Recipient> {
+ pub async fn recipient(&self, host: &str) -> anyhow::Result<impl Recipient + use<>> {
let key = self.key(host).await?;
age::ssh::Recipient::from_str(&key).map_err(|e| anyhow!("parse recipient error: {:?}", e))
}
- pub async fn recipients(&self, hosts: Vec<String>) -> Result<Vec<impl Recipient>> {
+ pub async fn recipients(&self, hosts: Vec<String>) -> Result<Vec<impl Recipient + use<>>> {
let hosts = self.expand_owner_set(hosts).await?;
futures::stream::iter(hosts.iter())
.then(|m| self.recipient(m.as_ref()))
crates/fleet-base/src/lib.rsdiffbeforeafterboth--- a/crates/fleet-base/src/lib.rs
+++ b/crates/fleet-base/src/lib.rs
@@ -1,6 +1,6 @@
pub mod command;
+pub mod deploy;
pub mod fleetdata;
pub mod host;
mod keys;
pub mod opts;
-pub mod deploy;
\ No newline at end of file
crates/fleet-base/src/opts.rsdiffbeforeafterboth--- a/crates/fleet-base/src/opts.rs
+++ b/crates/fleet-base/src/opts.rs
@@ -6,15 +6,15 @@
sync::{Arc, Mutex},
};
-use anyhow::{bail, Context, Result};
-use nix_eval::{nix_go, util::assert_warn, NixSessionPool, Value};
+use anyhow::{Context, Result, bail};
+use nix_eval::{NixSessionPool, Value, nix_go, util::assert_warn};
use nom::{
+ Parser,
bytes::complete::take_while1,
character::complete::char,
combinator::{map, opt},
multi::separated_list1,
sequence::{preceded, separated_pair},
- Parser,
};
use crate::{
@@ -44,7 +44,8 @@
let (input, name) = map(
take_while1(|v| v != ',' && v != '?' && v != '@'),
str::to_owned,
- ).parse_complete(input)
+ )
+ .parse_complete(input)
.map_err(err_to_string)?;
let kw_item = separated_pair(
crates/fleet-shared/src/encoding.rsdiffbeforeafterboth--- a/crates/fleet-shared/src/encoding.rs
+++ b/crates/fleet-shared/src/encoding.rs
@@ -3,8 +3,8 @@
str::FromStr,
};
-use base64::engine::{general_purpose::STANDARD_NO_PAD, Engine};
-use serde::{de::Error, Deserialize, Deserializer, Serialize};
+use base64::engine::{Engine, general_purpose::STANDARD_NO_PAD};
+use serde::{Deserialize, Deserializer, Serialize, de::Error};
use unicode_categories::UnicodeCategories;
#[derive(Debug, PartialEq, Clone)]
crates/nix-eval/src/pool.rsdiffbeforeafterboth--- a/crates/nix-eval/src/pool.rs
+++ b/crates/nix-eval/src/pool.rs
@@ -5,7 +5,7 @@
use r2d2::Pool;
-use crate::{session::NixSessionInner, Error, NixSession, Result};
+use crate::{Error, NixSession, Result, session::NixSessionInner};
pub struct NixSessionPool(Pool<NixSessionPoolInner>);
impl NixSessionPool {
crates/nix-eval/src/session.rsdiffbeforeafterboth--- a/crates/nix-eval/src/session.rs
+++ b/crates/nix-eval/src/session.rs
@@ -3,16 +3,16 @@
use better_command::{ClonableHandler, Handler, NixHandler, NoopHandler};
use futures::StreamExt;
use itertools::Itertools as _;
-use serde::{de::DeserializeOwned, Deserialize};
+use serde::{Deserialize, de::DeserializeOwned};
use thiserror::Error;
use tokio::{
io::AsyncWriteExt,
process::{ChildStderr, ChildStdin, ChildStdout, Command},
select,
- sync::{mpsc, oneshot, Mutex},
+ sync::{Mutex, mpsc, oneshot},
};
use tokio_util::codec::{FramedRead, LinesCodec};
-use tracing::{debug, error, warn, Level};
+use tracing::{Level, debug, error, warn};
#[derive(Error, Debug, Clone)]
pub enum Error {
crates/nix-eval/src/util.rsdiffbeforeafterboth--- a/crates/nix-eval/src/util.rs
+++ b/crates/nix-eval/src/util.rs
@@ -3,7 +3,7 @@
use anyhow::bail;
use tracing::{debug, warn};
-use crate::{nix_go_json, Value};
+use crate::{Value, nix_go_json};
#[tracing::instrument(level = "info", skip(val))]
pub async fn assert_warn(action: &str, val: &Value) -> anyhow::Result<()> {
crates/nix-eval/src/value.rsdiffbeforeafterboth1use std::{collections::HashMap, fmt, path::PathBuf, sync::Arc};23use better_command::NixHandler;4use serde::{de::DeserializeOwned, Serialize};56use crate::{macros::NixExprBuilder, nix_go, Error, NixBuildBatch, NixSession, Result};78#[derive(Clone)]9pub enum Index {10 Var(String),11 String(String),12 #[allow(dead_code)]13 Apply(String),14 #[allow(dead_code)]15 Expr(NixExprBuilder),16 ExprApply(NixExprBuilder),17 Pipe(NixExprBuilder),18 Merge(NixExprBuilder),19}20impl Index {21 pub fn var(v: impl AsRef<str>) -> Self {22 let v = v.as_ref();23 assert!(24 !(v.contains('.') | v.contains(' ')),25 "bad variable name: {v}"26 );27 Self::Var(v.to_owned())28 }29 pub fn attr(v: impl AsRef<str>) -> Self {30 Self::String(v.as_ref().to_owned())31 }32 #[allow(dead_code)]33 pub fn apply(v: impl Serialize) -> Self {34 let serialized = nixlike::serialize(v).expect("invalid value for apply");35 Self::Apply(serialized.trim_end().to_owned())36 }37}38impl fmt::Display for Index {39 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {40 match self {41 Index::Var(v) => {42 write!(f, "{v}")43 }44 Index::String(k) => {45 let v = nixlike::format_identifier(k.as_str());46 write!(f, ".{v}")47 }48 Index::Apply(_) => {49 write!(f, "<apply>(...)")50 }51 Index::Expr(e) => {52 write!(f, "[{}]", e.out)53 }54 Index::ExprApply(_) => {55 write!(f, "<apply>(...)")56 }57 Index::Pipe(e) => {58 write!(f, "<map>({})", e.out)59 }60 Index::Merge(e) => {61 write!(f, "//({})", e.out)62 }63 }64 }65}66impl fmt::Debug for Index {67 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {68 write!(f, "{self}")69 }70}71struct PathDisplay<'i>(&'i [Index]);72impl fmt::Display for PathDisplay<'_> {73 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {74 if !matches!(self.0.first(), Some(Index::Var(_))) {75 write!(f, "<unknown>")?;76 }77 for i in self.0 {78 write!(f, "{i}")?;79 }80 Ok(())81 }82}83struct ValueInner {84 full_path: Vec<Index>,85 session: NixSession,86 value: u32,87}88#[derive(Clone)]89pub struct Value(Arc<ValueInner>);90impl Value {91 async fn new(session: NixSession, query: &str) -> Result<Self> {92 let vid = session.0.lock().await.execute_assign(query).await?;93 Ok(Self(Arc::new(ValueInner {94 full_path: vec![],95 session,96 value: vid,97 })))98 }99 /// Get a top-level binding.100 ///101 /// In flake repl session, every output is exposed as top-level binding.102 pub async fn binding(session: NixSession, query: &str) -> Result<Self> {103 // TODO: Verify that query is a valid variable name104 let vid = session.0.lock().await.execute_assign(query).await?;105 Ok(Self(Arc::new(ValueInner {106 full_path: vec![Index::Var(query.to_owned())],107 session,108 value: vid,109 })))110 }111 pub async fn select(&self, name: impl IntoIterator<Item = Index>) -> Result<Self> {112 let mut used_fields = Vec::new();113 let name = name.into_iter();114115 let mut full_path = self.0.full_path.clone();116 let mut query = self.sess_field_name();117 for v in name {118 full_path.push(v.clone());119 match v {120 Index::Var(_) => panic!("var item may only be first"),121 Index::String(s) => {122 let escaped =123 nixlike::serialize(s).expect("strings are always serialized successfully");124 query.push('.');125 query.push_str(escaped.trim());126 }127 Index::Apply(a) => {128 // In cases like `a {}.b` first `{}.b` will be evaluated, so `a {}` should be encased in `()`129 query = format!("({query} {a})");130 }131 Index::Expr(e) => {132 let index = Value::new(self.0.session.clone(), &e.out).await?;133 used_fields.push(index.clone());134 query.push('.');135 let index = format!("${{sess_field_{}}}", index.0.value);136 query.push_str(&index);137 }138 Index::ExprApply(e) => {139 let index = Value::new(self.0.session.clone(), &e.out).await?;140 used_fields.push(index.clone());141 query.push(' ');142 let index = format!("sess_field_{}", index.0.value);143 query.push_str(&index);144 query = format!("({query})");145 }146 Index::Pipe(v) => {147 let index = Value::new(self.0.session.clone(), &v.out).await?;148 used_fields.push(index.clone());149 let index = format!("sess_field_{}", index.0.value);150 query = format!("({index} {query})");151 }152 Index::Merge(v) => {153 let index = Value::new(self.0.session.clone(), &v.out).await?;154 used_fields.push(index.clone());155 let index = format!("sess_field_{}", index.0.value);156 query = format!("({query} // {index})");157 }158 }159 }160161 let vid = self162 .0163 .session164 .0165 .lock()166 .await167 .execute_assign(&query)168 .await169 .map_err(|e| e.context(self.attribute()))?;170 Ok(Self(Arc::new(ValueInner {171 full_path,172 session: self.0.session.clone(),173 value: vid,174 })))175 }176 pub async fn as_json<V: DeserializeOwned>(&self) -> Result<V> {177 let query = self.sess_field_name();178 self.0179 .session180 .0181 .lock()182 .await183 .execute_expression_to_json(&query)184 .await185 .map_err(|e| e.context(self.attribute()))186 }187 #[allow(dead_code)]188 pub async fn has_field(&self, name: &str) -> Result<bool> {189 let key = nixlike::escape_string(name);190 let query = format!("{} ? {key}", self.sess_field_name());191 self.0192 .session193 .0194 .lock()195 .await196 .execute_expression_to_json(&query)197 .await198 .map_err(|e| e.context(self.attribute()))199 }200 pub async fn list_fields(&self) -> Result<Vec<String>> {201 let query = format!("builtins.attrNames {}", self.sess_field_name());202 self.0203 .session204 .0205 .lock()206 .await207 .execute_expression_to_json(&query)208 .await209 .map_err(|e| e.context(self.attribute()))210 }211 pub async fn type_of(&self) -> Result<String> {212 let query = format!("builtins.typeOf {}", self.sess_field_name());213 self.0214 .session215 .0216 .lock()217 .await218 .execute_expression_to_json(&query)219 .await220 .map_err(|e| e.context(self.attribute()))221 }222 #[allow(dead_code)]223 pub async fn import(&self) -> Result<Self> {224 let import = Self::new(self.0.session.clone(), "import").await?;225 Ok(nix_go!(self | import))226 }227 fn sess_field_name(&self) -> String {228 format!("sess_field_{}", self.0.value)229 }230 pub async fn build_maybe_batch(231 &self,232 batch: Option<NixBuildBatch>,233 ) -> Result<HashMap<String, PathBuf>> {234 if let Some(batch) = batch {235 batch.submit(self.clone()).await236 } else {237 self.build().await238 }239 }240 pub async fn build(&self) -> Result<HashMap<String, PathBuf>> {241 let query = format!(":b {}", self.sess_field_name());242 let vid = self243 .0244 .session245 .0246 .lock()247 .await248 .execute_expression_raw(&query, &mut NixHandler::default())249 .await?;250 if vid.is_empty() {251 return Err(Error::BuildFailed {252 attribute: self.attribute(),253 error: "build produced no output".to_owned(),254 });255 }256 let Some(vid) = vid.strip_prefix("This derivation produced the following outputs:\n")257 else {258 return Err(Error::BuildFailed {259 attribute: self.attribute(),260 error: format!("failed to parse output: {vid}"),261 });262 };263 let outputs = vid264 .split('\n')265 .filter(|v| !v.is_empty())266 .map(|v| v.split_once(" -> ").expect("unexpected build output"))267 .map(|(a, b)| (a.trim_start().to_owned(), PathBuf::from(b)))268 .collect();269 Ok(outputs)270 }271 /// Weakly convert string-like types (derivation/path/string) to string272 pub async fn to_string_weak(&self) -> Result<String> {273 let query = format!("\"${{{}}}\"", self.sess_field_name());274 let vid: String = self275 .0276 .session277 .0278 .lock()279 .await280 .execute_expression_to_json(&query)281 .await?;282 Ok(vid)283 }284285 fn attribute(&self) -> String {286 PathDisplay(&self.0.full_path).to_string()287 }288289 pub(crate) fn session(&self) -> NixSession {290 self.0.session.clone()291 }292293 pub(crate) fn session_field_id(&self) -> u32 {294 self.0.value295 }296}297impl Drop for ValueInner {298 fn drop(&mut self) {299 if let Ok(mut lock) = self.session.0.try_lock() {300 lock.free_list.push(self.value)301 }302 // Leaked303 }304}1use std::{collections::HashMap, fmt, path::PathBuf, sync::Arc};23use better_command::NixHandler;4use serde::{Serialize, de::DeserializeOwned};56use crate::{Error, NixBuildBatch, NixSession, Result, macros::NixExprBuilder, nix_go};78#[derive(Clone)]9pub enum Index {10 Var(String),11 String(String),12 #[allow(dead_code)]13 Apply(String),14 #[allow(dead_code)]15 Expr(NixExprBuilder),16 ExprApply(NixExprBuilder),17 Pipe(NixExprBuilder),18 Merge(NixExprBuilder),19}20impl Index {21 pub fn var(v: impl AsRef<str>) -> Self {22 let v = v.as_ref();23 assert!(24 !(v.contains('.') | v.contains(' ')),25 "bad variable name: {v}"26 );27 Self::Var(v.to_owned())28 }29 pub fn attr(v: impl AsRef<str>) -> Self {30 Self::String(v.as_ref().to_owned())31 }32 #[allow(dead_code)]33 pub fn apply(v: impl Serialize) -> Self {34 let serialized = nixlike::serialize(v).expect("invalid value for apply");35 Self::Apply(serialized.trim_end().to_owned())36 }37}38impl fmt::Display for Index {39 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {40 match self {41 Index::Var(v) => {42 write!(f, "{v}")43 }44 Index::String(k) => {45 let v = nixlike::format_identifier(k.as_str());46 write!(f, ".{v}")47 }48 Index::Apply(_) => {49 write!(f, "<apply>(...)")50 }51 Index::Expr(e) => {52 write!(f, "[{}]", e.out)53 }54 Index::ExprApply(_) => {55 write!(f, "<apply>(...)")56 }57 Index::Pipe(e) => {58 write!(f, "<map>({})", e.out)59 }60 Index::Merge(e) => {61 write!(f, "//({})", e.out)62 }63 }64 }65}66impl fmt::Debug for Index {67 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {68 write!(f, "{self}")69 }70}71struct PathDisplay<'i>(&'i [Index]);72impl fmt::Display for PathDisplay<'_> {73 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {74 if !matches!(self.0.first(), Some(Index::Var(_))) {75 write!(f, "<unknown>")?;76 }77 for i in self.0 {78 write!(f, "{i}")?;79 }80 Ok(())81 }82}83struct ValueInner {84 full_path: Vec<Index>,85 session: NixSession,86 value: u32,87}88#[derive(Clone)]89pub struct Value(Arc<ValueInner>);90impl Value {91 async fn new(session: NixSession, query: &str) -> Result<Self> {92 let vid = session.0.lock().await.execute_assign(query).await?;93 Ok(Self(Arc::new(ValueInner {94 full_path: vec![],95 session,96 value: vid,97 })))98 }99 /// Get a top-level binding.100 ///101 /// In flake repl session, every output is exposed as top-level binding.102 pub async fn binding(session: NixSession, query: &str) -> Result<Self> {103 // TODO: Verify that query is a valid variable name104 let vid = session.0.lock().await.execute_assign(query).await?;105 Ok(Self(Arc::new(ValueInner {106 full_path: vec![Index::Var(query.to_owned())],107 session,108 value: vid,109 })))110 }111 pub async fn select(&self, name: impl IntoIterator<Item = Index>) -> Result<Self> {112 let mut used_fields = Vec::new();113 let name = name.into_iter();114115 let mut full_path = self.0.full_path.clone();116 let mut query = self.sess_field_name();117 for v in name {118 full_path.push(v.clone());119 match v {120 Index::Var(_) => panic!("var item may only be first"),121 Index::String(s) => {122 let escaped =123 nixlike::serialize(s).expect("strings are always serialized successfully");124 query.push('.');125 query.push_str(escaped.trim());126 }127 Index::Apply(a) => {128 // In cases like `a {}.b` first `{}.b` will be evaluated, so `a {}` should be encased in `()`129 query = format!("({query} {a})");130 }131 Index::Expr(e) => {132 let index = Value::new(self.0.session.clone(), &e.out).await?;133 used_fields.push(index.clone());134 query.push('.');135 let index = format!("${{sess_field_{}}}", index.0.value);136 query.push_str(&index);137 }138 Index::ExprApply(e) => {139 let index = Value::new(self.0.session.clone(), &e.out).await?;140 used_fields.push(index.clone());141 query.push(' ');142 let index = format!("sess_field_{}", index.0.value);143 query.push_str(&index);144 query = format!("({query})");145 }146 Index::Pipe(v) => {147 let index = Value::new(self.0.session.clone(), &v.out).await?;148 used_fields.push(index.clone());149 let index = format!("sess_field_{}", index.0.value);150 query = format!("({index} {query})");151 }152 Index::Merge(v) => {153 let index = Value::new(self.0.session.clone(), &v.out).await?;154 used_fields.push(index.clone());155 let index = format!("sess_field_{}", index.0.value);156 query = format!("({query} // {index})");157 }158 }159 }160161 let vid = self162 .0163 .session164 .0165 .lock()166 .await167 .execute_assign(&query)168 .await169 .map_err(|e| e.context(self.attribute()))?;170 Ok(Self(Arc::new(ValueInner {171 full_path,172 session: self.0.session.clone(),173 value: vid,174 })))175 }176 pub async fn as_json<V: DeserializeOwned>(&self) -> Result<V> {177 let query = self.sess_field_name();178 self.0179 .session180 .0181 .lock()182 .await183 .execute_expression_to_json(&query)184 .await185 .map_err(|e| e.context(self.attribute()))186 }187 #[allow(dead_code)]188 pub async fn has_field(&self, name: &str) -> Result<bool> {189 let key = nixlike::escape_string(name);190 let query = format!("{} ? {key}", self.sess_field_name());191 self.0192 .session193 .0194 .lock()195 .await196 .execute_expression_to_json(&query)197 .await198 .map_err(|e| e.context(self.attribute()))199 }200 pub async fn list_fields(&self) -> Result<Vec<String>> {201 let query = format!("builtins.attrNames {}", self.sess_field_name());202 self.0203 .session204 .0205 .lock()206 .await207 .execute_expression_to_json(&query)208 .await209 .map_err(|e| e.context(self.attribute()))210 }211 pub async fn type_of(&self) -> Result<String> {212 let query = format!("builtins.typeOf {}", self.sess_field_name());213 self.0214 .session215 .0216 .lock()217 .await218 .execute_expression_to_json(&query)219 .await220 .map_err(|e| e.context(self.attribute()))221 }222 #[allow(dead_code)]223 pub async fn import(&self) -> Result<Self> {224 let import = Self::new(self.0.session.clone(), "import").await?;225 Ok(nix_go!(self | import))226 }227 fn sess_field_name(&self) -> String {228 format!("sess_field_{}", self.0.value)229 }230 pub async fn build_maybe_batch(231 &self,232 batch: Option<NixBuildBatch>,233 ) -> Result<HashMap<String, PathBuf>> {234 if let Some(batch) = batch {235 batch.submit(self.clone()).await236 } else {237 self.build().await238 }239 }240 pub async fn build(&self) -> Result<HashMap<String, PathBuf>> {241 let query = format!(":b {}", self.sess_field_name());242 let vid = self243 .0244 .session245 .0246 .lock()247 .await248 .execute_expression_raw(&query, &mut NixHandler::default())249 .await?;250 if vid.is_empty() {251 return Err(Error::BuildFailed {252 attribute: self.attribute(),253 error: "build produced no output".to_owned(),254 });255 }256 let Some(vid) = vid.strip_prefix("This derivation produced the following outputs:\n")257 else {258 return Err(Error::BuildFailed {259 attribute: self.attribute(),260 error: format!("failed to parse output: {vid}"),261 });262 };263 let outputs = vid264 .split('\n')265 .filter(|v| !v.is_empty())266 .map(|v| v.split_once(" -> ").expect("unexpected build output"))267 .map(|(a, b)| (a.trim_start().to_owned(), PathBuf::from(b)))268 .collect();269 Ok(outputs)270 }271 /// Weakly convert string-like types (derivation/path/string) to string272 pub async fn to_string_weak(&self) -> Result<String> {273 let query = format!("\"${{{}}}\"", self.sess_field_name());274 let vid: String = self275 .0276 .session277 .0278 .lock()279 .await280 .execute_expression_to_json(&query)281 .await?;282 Ok(vid)283 }284285 fn attribute(&self) -> String {286 PathDisplay(&self.0.full_path).to_string()287 }288289 pub(crate) fn session(&self) -> NixSession {290 self.0.session.clone()291 }292293 pub(crate) fn session_field_id(&self) -> u32 {294 self.0.value295 }296}297impl Drop for ValueInner {298 fn drop(&mut self) {299 if let Ok(mut lock) = self.session.0.try_lock() {300 lock.free_list.push(self.value)301 }302 // Leaked303 }304}crates/nix-native-eval/Cargo.tomldiffbeforeafterboth--- a/crates/nix-native-eval/Cargo.toml
+++ /dev/null
@@ -1,10 +0,0 @@
-[package]
-name = "nix-native-eval"
-version.workspace = true
-edition.workspace = true
-rust-version.workspace = true
-
-[dependencies]
-anyhow.workspace = true
-
-nixrs = { git = "https://github.com/Anillc/nixrs", version = "0.1.0" }
crates/nix-native-eval/src/lib.rsdiffbeforeafterboth--- a/crates/nix-native-eval/src/lib.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-use anyhow::Result;
-use nixrs::{State, Store};
-
-pub fn init() -> Result<()> {
- nixrs::init()?;
- let store = Store::new("daemon")?;
- let state = State::new(store)?;
- let _ = state;
-
- Ok(())
-}
crates/nixlike/fuzz/Cargo.tomldiffbeforeafterboth--- a/crates/nixlike/fuzz/Cargo.toml
+++ b/crates/nixlike/fuzz/Cargo.toml
@@ -4,7 +4,7 @@
version = "0.0.0"
authors = ["Automatically generated"]
publish = false
-edition = "2021"
+edition = "2024"
[package.metadata]
cargo-fuzz = true
crates/nixlike/src/de_impl.rsdiffbeforeafterboth--- a/crates/nixlike/src/de_impl.rs
+++ b/crates/nixlike/src/de_impl.rs
@@ -2,8 +2,8 @@
use linked_hash_map::LinkedHashMap;
use serde::{
+ Deserializer,
de::{self, MapAccess, SeqAccess},
- Deserializer,
};
use crate::{Error, Value};
@@ -28,11 +28,12 @@
where
K: de::DeserializeSeed<'de>,
{
- if let Some((k, v)) = self.iter.next() {
- let _ = self.value.insert(v);
- Ok(Some(seed.deserialize(Value::String(k))?))
- } else {
- Ok(None)
+ match self.iter.next() {
+ Some((k, v)) => {
+ let _ = self.value.insert(v);
+ Ok(Some(seed.deserialize(Value::String(k))?))
+ }
+ _ => Ok(None),
}
}
@@ -62,10 +63,9 @@
where
T: de::DeserializeSeed<'de>,
{
- if let Some(v) = self.iter.next() {
- Ok(Some(seed.deserialize(v)?))
- } else {
- Ok(None)
+ match self.iter.next() {
+ Some(v) => Ok(Some(seed.deserialize(v)?)),
+ _ => Ok(None),
}
}
}
crates/nixlike/src/se_impl.rsdiffbeforeafterboth--- a/crates/nixlike/src/se_impl.rs
+++ b/crates/nixlike/src/se_impl.rs
@@ -2,11 +2,11 @@
use linked_hash_map::LinkedHashMap;
use serde::{
+ Serializer,
ser::{
self, SerializeMap, SerializeSeq, SerializeStruct, SerializeStructVariant, SerializeTuple,
SerializeTupleStruct, SerializeTupleVariant,
},
- Serializer,
};
use crate::{Error, Value};
@@ -90,9 +90,7 @@
fn end(self) -> Result<Self::Ok, Self::Error> {
Ok(Value::Object(
- vec![(self.0, Value::Array(self.1 .0))]
- .into_iter()
- .collect(),
+ vec![(self.0, Value::Array(self.1.0))].into_iter().collect(),
))
}
}
flake.lockdiffbeforeafterboth--- a/flake.lock
+++ b/flake.lock
@@ -2,11 +2,11 @@
"nodes": {
"crane": {
"locked": {
- "lastModified": 1739936662,
- "narHash": "sha256-x4syUjNUuRblR07nDPeLDP7DpphaBVbUaSoeZkFbGSk=",
+ "lastModified": 1750266157,
+ "narHash": "sha256-tL42YoNg9y30u7zAqtoGDNdTyXTi8EALDeCB13FtbQA=",
"owner": "ipetkov",
"repo": "crane",
- "rev": "19de14aaeb869287647d9461cbd389187d8ecdb7",
+ "rev": "e37c943371b73ed87faf33f7583860f81f1d5a48",
"type": "github"
},
"original": {
@@ -22,11 +22,11 @@
]
},
"locked": {
- "lastModified": 1738453229,
- "narHash": "sha256-7H9XgNiGLKN1G1CgRh0vUL4AheZSYzPm+zmZ7vxbJdo=",
+ "lastModified": 1749398372,
+ "narHash": "sha256-tYBdgS56eXYaWVW3fsnPQ/nFlgWi/Z2Ymhyu21zVM98=",
"owner": "hercules-ci",
"repo": "flake-parts",
- "rev": "32ea77a06711b758da0ad9bd6a844c5740a87abd",
+ "rev": "9305fe4e5c2a6fcf5ba6a3ff155720fbe4076569",
"type": "github"
},
"original": {
@@ -37,16 +37,16 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1740339700,
- "narHash": "sha256-cbrw7EgQhcdFnu6iS3vane53bEagZQy/xyIkDWpCgVE=",
+ "lastModified": 1750895632,
+ "narHash": "sha256-EPZWiRmaSTxoBArK5dQyRlSNVLXiBt2hmsYIPgMf3zk=",
"owner": "nixos",
"repo": "nixpkgs",
- "rev": "04ef94c4c1582fd485bbfdb8c4a8ba250e359195",
+ "rev": "6ac57ce7fee0d80226095a57ccb7519855ad7c5e",
"type": "github"
},
"original": {
"owner": "nixos",
- "ref": "release-24.11",
+ "ref": "release-25.05",
"repo": "nixpkgs",
"type": "github"
}
@@ -68,11 +68,11 @@
]
},
"locked": {
- "lastModified": 1740277845,
- "narHash": "sha256-NNU0CdiaSbAeZ8tpDG4aFi9qtcdlItRvk8Xns9oBrVU=",
+ "lastModified": 1750819193,
+ "narHash": "sha256-XvkupGPZqD54HuKhN/2WhbKjAHeTl1UEnWspzUzRFfA=",
"owner": "oxalica",
"repo": "rust-overlay",
- "rev": "f933070c29f9c1c5457447a51903f27f76ebb519",
+ "rev": "1ba3b9c59b68a4b00156827ad46393127b51b808",
"type": "github"
},
"original": {
@@ -103,11 +103,11 @@
]
},
"locked": {
- "lastModified": 1744961264,
- "narHash": "sha256-aRmUh0AMwcbdjJHnytg1e5h5ECcaWtIFQa6d9gI85AI=",
+ "lastModified": 1749194973,
+ "narHash": "sha256-eEy8cuS0mZ2j/r/FE0/LYBSBcIs/MKOIVakwHVuqTfk=",
"owner": "numtide",
"repo": "treefmt-nix",
- "rev": "8d404a69efe76146368885110f29a2ca3700bee6",
+ "rev": "a05be418a1af1198ca0f63facb13c985db4cb3c5",
"type": "github"
},
"original": {
flake.nixdiffbeforeafterboth--- a/flake.nix
+++ b/flake.nix
@@ -2,7 +2,7 @@
description = "NixOS cluster configuration management";
inputs = {
- nixpkgs.url = "github:nixos/nixpkgs/release-24.11";
+ nixpkgs.url = "github:nixos/nixpkgs/release-25.05";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
@@ -156,7 +156,7 @@
bacon
nil
rustPlatform.bindgenHook
- nixVersions.nix_2_22
+ # nixVersions.nix_2_22
];
environment.PROTOC = "${pkgs.protobuf}/bin/protoc";
};
rust-toolchain.tomldiffbeforeafterboth--- a/rust-toolchain.toml
+++ b/rust-toolchain.toml
@@ -1,3 +1,3 @@
[toolchain]
-channel = "1.85.0"
+channel = "1.86.0"
components = ["rustfmt", "clippy", "rust-analyzer", "rust-src"]
rustfmt.tomldiffbeforeafterboth--- a/rustfmt.toml
+++ b/rustfmt.toml
@@ -1,3 +1,3 @@
hard_tabs = true
-imports_granularity = "Crate"
-group_imports = "StdExternalCrate"
+# imports_granularity = "Crate"
+# group_imports = "StdExternalCrate"