chore(glue): upgrade to 2024 edition

Part of #114
cargo fix wanted to rewrite `if let else` to match statements, but i
reverted them as they dont belong in this cl.
There weren't any warnings about locks (relative drop order changed in
2024)

Change-Id: I9c851ef8e214a481cbe7b4cf9b2634b5d56970d4
Reviewed-on: https://cl.snix.dev/c/snix/+/30369
Autosubmit: Bence Nemes <nemes.bence1@gmail.com>
Reviewed-by: Ilan Joselevich <personal@ilanjoselevich.com>
Reviewed-by: Florian Klink <flokli@flokli.de>
Tested-by: besadii
This commit is contained in:
Starnick4444 2025-05-01 10:30:20 +02:00 committed by clbot
parent 916988a7a2
commit 1a84bc0e62
15 changed files with 36 additions and 32 deletions

View file

@ -14335,7 +14335,7 @@ rec {
"snix-glue" = rec { "snix-glue" = rec {
crateName = "snix-glue"; crateName = "snix-glue";
version = "0.1.0"; version = "0.1.0";
edition = "2021"; edition = "2024";
src = lib.cleanSourceWith { filter = sourceFilter; src = ./glue; }; src = lib.cleanSourceWith { filter = sourceFilter; src = ./glue; };
libName = "snix_glue"; libName = "snix_glue";
dependencies = [ dependencies = [

View file

@ -1,7 +1,7 @@
[package] [package]
name = "snix-glue" name = "snix-glue"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2024"
[dependencies] [dependencies]
async-compression = { workspace = true, features = [ async-compression = { workspace = true, features = [

View file

@ -1,15 +1,15 @@
use clap::Parser; use clap::Parser;
use criterion::{black_box, criterion_group, criterion_main, Criterion}; use criterion::{Criterion, black_box, criterion_group, criterion_main};
use mimalloc::MiMalloc; use mimalloc::MiMalloc;
use snix_build::buildservice::DummyBuildService; use snix_build::buildservice::DummyBuildService;
use snix_eval::{builtins::impure_builtins, EvalIO}; use snix_eval::{EvalIO, builtins::impure_builtins};
use snix_glue::{ use snix_glue::{
builtins::{add_derivation_builtins, add_fetcher_builtins, add_import_builtins}, builtins::{add_derivation_builtins, add_fetcher_builtins, add_import_builtins},
configure_nix_path, configure_nix_path,
snix_io::SnixIO, snix_io::SnixIO,
snix_store_io::SnixStoreIO, snix_store_io::SnixStoreIO,
}; };
use snix_store::utils::{construct_services, ServiceUrlsMemory}; use snix_store::utils::{ServiceUrlsMemory, construct_services};
use std::sync::LazyLock; use std::sync::LazyLock;
use std::{env, rc::Rc, sync::Arc, time::Duration}; use std::{env, rc::Rc, sync::Arc, time::Duration};

2
snix/glue/rustfmt.toml Normal file
View file

@ -0,0 +1,2 @@
# FUTUREWORK: move to .. once all crates are migrated (#114)
edition = "2024"

View file

@ -7,11 +7,11 @@ use nix_compat::derivation::{Derivation, Output};
use nix_compat::nixhash; use nix_compat::nixhash;
use nix_compat::store_path::{StorePath, StorePathRef}; use nix_compat::store_path::{StorePath, StorePathRef};
use snix_eval::builtin_macros::builtins; use snix_eval::builtin_macros::builtins;
use snix_eval::generators::{self, emit_warning_kind, GenCo}; use snix_eval::generators::{self, GenCo, emit_warning_kind};
use snix_eval::{ use snix_eval::{
AddContext, ErrorKind, NixAttrs, NixContext, NixContextElement, Value, WarningKind, AddContext, ErrorKind, NixAttrs, NixContext, NixContextElement, Value, WarningKind,
}; };
use std::collections::{btree_map, BTreeSet}; use std::collections::{BTreeSet, btree_map};
use std::rc::Rc; use std::rc::Rc;
// Constants used for strangely named fields in derivation inputs. // Constants used for strangely named fields in derivation inputs.
@ -146,7 +146,7 @@ fn handle_fixed_output(
None | Some("flat") => Some(nixhash::CAHash::Flat(nixhash)), None | Some("flat") => Some(nixhash::CAHash::Flat(nixhash)),
Some("recursive") => Some(nixhash::CAHash::Nar(nixhash)), Some("recursive") => Some(nixhash::CAHash::Nar(nixhash)),
Some(other) => { Some(other) => {
return Err(DerivationError::InvalidOutputHashMode(other.to_string()))? return Err(DerivationError::InvalidOutputHashMode(other.to_string()))?;
} }
}, },
}, },

View file

@ -2,7 +2,7 @@
use super::utils::select_string; use super::utils::select_string;
use crate::{ use crate::{
fetchers::{url_basename, Fetch}, fetchers::{Fetch, url_basename},
snix_store_io::SnixStoreIO, snix_store_io::SnixStoreIO,
}; };
use nix_compat::nixhash; use nix_compat::nixhash;

View file

@ -1,12 +1,12 @@
//! Implements builtins used to import paths in the store. //! Implements builtins used to import paths in the store.
use crate::snix_store_io::SnixStoreIO; use crate::snix_store_io::SnixStoreIO;
use snix_castore::import::ingest_entries;
use snix_castore::Node; use snix_castore::Node;
use snix_castore::import::ingest_entries;
use snix_eval::{ use snix_eval::{
ErrorKind, EvalIO, Value,
builtin_macros::builtins, builtin_macros::builtins,
generators::{self, GenCo}, generators::{self, GenCo},
ErrorKind, EvalIO, Value,
}; };
use std::path::Path; use std::path::Path;
@ -112,13 +112,13 @@ mod import_builtins {
use crate::snix_store_io::SnixStoreIO; use crate::snix_store_io::SnixStoreIO;
use bstr::ByteSlice; use bstr::ByteSlice;
use nix_compat::nixhash::{CAHash, NixHash}; use nix_compat::nixhash::{CAHash, NixHash};
use nix_compat::store_path::{build_ca_path, StorePath, StorePathRef}; use nix_compat::store_path::{StorePath, StorePathRef, build_ca_path};
use sha2::Digest; use sha2::Digest;
use snix_castore::blobservice::BlobService; use snix_castore::blobservice::BlobService;
use snix_eval::builtins::coerce_value_to_path; use snix_eval::builtins::coerce_value_to_path;
use snix_eval::generators::Gen; use snix_eval::generators::Gen;
use snix_eval::{generators::GenCo, ErrorKind, Value};
use snix_eval::{AddContext, FileType, NixContext, NixContextElement, NixString}; use snix_eval::{AddContext, FileType, NixContext, NixContextElement, NixString};
use snix_eval::{ErrorKind, Value, generators::GenCo};
use snix_store::path_info::PathInfo; use snix_store::path_info::PathInfo;
use std::rc::Rc; use std::rc::Rc;
use tokio::io::AsyncWriteExt; use tokio::io::AsyncWriteExt;
@ -239,7 +239,7 @@ mod import_builtins {
} }
FileType::Directory if !recursive_ingestion => { FileType::Directory if !recursive_ingestion => {
return Err(ImportError::FlatImportOfNonFile(path))? return Err(ImportError::FlatImportOfNonFile(path))?;
} }
// do the filtered ingest // do the filtered ingest
@ -265,7 +265,7 @@ mod import_builtins {
std::io::ErrorKind::Unsupported, std::io::ErrorKind::Unsupported,
"unsupported file type", "unsupported file type",
)), )),
}) });
} }
}; };
@ -418,7 +418,7 @@ mod import_builtins {
return Err(ErrorKind::TypeError { return Err(ErrorKind::TypeError {
expected: "string or path", expected: "string or path",
actual: path.type_of(), actual: path.type_of(),
}) });
} }
}; };

View file

@ -69,7 +69,7 @@ mod tests {
use rstest::rstest; use rstest::rstest;
use snix_build::buildservice::DummyBuildService; use snix_build::buildservice::DummyBuildService;
use snix_eval::{EvalIO, EvaluationResult}; use snix_eval::{EvalIO, EvaluationResult};
use snix_store::utils::{construct_services, ServiceUrlsMemory}; use snix_store::utils::{ServiceUrlsMemory, construct_services};
use tempfile::TempDir; use tempfile::TempDir;
/// evaluates a given nix expression and returns the result. /// evaluates a given nix expression and returns the result.

View file

@ -1,7 +1,7 @@
use bstr::ByteSlice; use bstr::ByteSlice;
use snix_eval::{ use snix_eval::{
generators::{self, GenCo},
CatchableErrorKind, CoercionKind, ErrorKind, NixAttrs, NixString, Value, CatchableErrorKind, CoercionKind, ErrorKind, NixAttrs, NixString, Value,
generators::{self, GenCo},
}; };
pub(super) async fn strong_importing_coerce_to_string( pub(super) async fn strong_importing_coerce_to_string(

View file

@ -1,19 +1,19 @@
use futures::TryStreamExt; use futures::TryStreamExt;
use md5::{digest::DynDigest, Md5}; use md5::{Md5, digest::DynDigest};
use nix_compat::{ use nix_compat::{
nixhash::{CAHash, HashAlgo, NixHash}, nixhash::{CAHash, HashAlgo, NixHash},
store_path::{build_ca_path, BuildStorePathError, StorePathRef}, store_path::{BuildStorePathError, StorePathRef, build_ca_path},
}; };
use sha1::Sha1; use sha1::Sha1;
use sha2::{digest::Output, Digest, Sha256, Sha512}; use sha2::{Digest, Sha256, Sha512, digest::Output};
use snix_castore::{blobservice::BlobService, directoryservice::DirectoryService, Node}; use snix_castore::{Node, blobservice::BlobService, directoryservice::DirectoryService};
use snix_store::{ use snix_store::{
nar::{NarCalculationService, NarIngestionError}, nar::{NarCalculationService, NarIngestionError},
pathinfoservice::{PathInfo, PathInfoService}, pathinfoservice::{PathInfo, PathInfoService},
}; };
use tokio::io::{AsyncBufRead, AsyncRead, AsyncWrite, AsyncWriteExt, BufReader}; use tokio::io::{AsyncBufRead, AsyncRead, AsyncWrite, AsyncWriteExt, BufReader};
use tokio_util::io::{InspectReader, InspectWriter}; use tokio_util::io::{InspectReader, InspectWriter};
use tracing::{instrument, warn, Span}; use tracing::{Span, instrument, warn};
use tracing_indicatif::span_ext::IndicatifSpanExt; use tracing_indicatif::span_ext::IndicatifSpanExt;
use url::Url; use url::Url;

View file

@ -47,7 +47,7 @@ pub(crate) fn fetchurl_derivation_to_fetch(drv: &Derivation) -> Result<(String,
url, url,
exp_hash: Some(hash), exp_hash: Some(hash),
}, },
)) ));
} }
CAHash::Nar(hash) => { CAHash::Nar(hash) => {
if drv.environment.get("executable").map(|v| v.as_slice()) == Some(b"1") { if drv.environment.get("executable").map(|v| v.as_slice()) == Some(b"1") {

View file

@ -279,9 +279,11 @@ mod tests {
let mut known_paths = KnownPaths::default(); let mut known_paths = KnownPaths::default();
// get_fetch_for_output_path should return None for new fetches. // get_fetch_for_output_path should return None for new fetches.
assert!(known_paths assert!(
known_paths
.get_fetch_for_output_path(&FETCH_TARBALL_OUT_PATH) .get_fetch_for_output_path(&FETCH_TARBALL_OUT_PATH)
.is_none()); .is_none()
);
// add_fetch should return the properly calculated store paths. // add_fetch should return the properly calculated store paths.
assert_eq!( assert_eq!(

View file

@ -40,7 +40,7 @@ pub(crate) fn get_all_inputs<'a, F, Fut>(
derivation: &'a Derivation, derivation: &'a Derivation,
known_paths: &'a KnownPaths, known_paths: &'a KnownPaths,
get_path_info: F, get_path_info: F,
) -> impl Stream<Item = Result<(StorePath<String>, Node), std::io::Error>> ) -> impl Stream<Item = Result<(StorePath<String>, Node), std::io::Error>> + use<F, Fut>
where where
F: Fn(StorePath<String>) -> Fut, F: Fn(StorePath<String>) -> Fut,
Fut: Future<Output = std::io::Result<Option<PathInfo>>>, Fut: Future<Output = std::io::Result<Option<PathInfo>>>,

View file

@ -11,13 +11,13 @@ use std::{
sync::Arc, sync::Arc,
}; };
use tokio_util::io::SyncIoBridge; use tokio_util::io::SyncIoBridge;
use tracing::{error, instrument, warn, Level, Span}; use tracing::{Level, Span, error, instrument, warn};
use tracing_indicatif::span_ext::IndicatifSpanExt; use tracing_indicatif::span_ext::IndicatifSpanExt;
use snix_castore::{ use snix_castore::{
Node,
blobservice::BlobService, blobservice::BlobService,
directoryservice::{self, DirectoryService}, directoryservice::{self, DirectoryService},
Node,
}; };
use snix_store::pathinfoservice::{PathInfo, PathInfoService}; use snix_store::pathinfoservice::{PathInfo, PathInfoService};
@ -489,7 +489,7 @@ mod tests {
use clap::Parser; use clap::Parser;
use snix_build::buildservice::DummyBuildService; use snix_build::buildservice::DummyBuildService;
use snix_eval::{EvalIO, EvaluationResult}; use snix_eval::{EvalIO, EvaluationResult};
use snix_store::utils::{construct_services, ServiceUrlsMemory}; use snix_store::utils::{ServiceUrlsMemory, construct_services};
use tempfile::TempDir; use tempfile::TempDir;
use super::SnixStoreIO; use super::SnixStoreIO;

View file

@ -4,7 +4,7 @@ use clap::Parser;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use snix_build::buildservice::DummyBuildService; use snix_build::buildservice::DummyBuildService;
use snix_eval::{EvalIO, EvalMode, Value}; use snix_eval::{EvalIO, EvalMode, Value};
use snix_store::utils::{construct_services, ServiceUrlsMemory}; use snix_store::utils::{ServiceUrlsMemory, construct_services};
use std::path::PathBuf; use std::path::PathBuf;
use rstest::rstest; use rstest::rstest;