diff --git a/Cargo.lock b/Cargo.lock index b96fa37..7e1d1f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -564,7 +564,6 @@ dependencies = [ "anyhow", "cstr", "ctor", - "lazy_static", "nix-bindings-bdwgc-sys", "nix-bindings-expr-sys", "nix-bindings-store", @@ -614,7 +613,6 @@ dependencies = [ "anyhow", "cstr", "ctor", - "lazy_static", "nix-bindings-expr", "nix-bindings-fetchers", "nix-bindings-flake-sys", @@ -644,7 +642,6 @@ dependencies = [ "ctor", "harmonia-store-core", "hex-literal", - "lazy_static", "nix-bindings-store-sys", "nix-bindings-util", "nix-bindings-util-sys", diff --git a/nix-bindings-expr/Cargo.toml b/nix-bindings-expr/Cargo.toml index 616bd96..4b1c777 100644 --- a/nix-bindings-expr/Cargo.toml +++ b/nix-bindings-expr/Cargo.toml @@ -19,7 +19,6 @@ nix-bindings-bdwgc-sys = { path = "../nix-bindings-bdwgc-sys", version = "0.2.1" nix-bindings-util-sys = { path = "../nix-bindings-util-sys", version = "0.2.1" } nix-bindings-store-sys = { path = "../nix-bindings-store-sys", version = "0.2.1" } nix-bindings-expr-sys = { path = "../nix-bindings-expr-sys", version = "0.2.1" } -lazy_static = "1.4" ctor = "0.2" tempfile = "3.10" cstr = "0.2" diff --git a/nix-bindings-expr/src/eval_state.rs b/nix-bindings-expr/src/eval_state.rs index c05ae9b..b8e27e6 100644 --- a/nix-bindings-expr/src/eval_state.rs +++ b/nix-bindings-expr/src/eval_state.rs @@ -133,7 +133,6 @@ use crate::value::{Int, Value, ValueType}; use anyhow::Context as _; use anyhow::{bail, Result}; use cstr::cstr; -use lazy_static::lazy_static; use nix_bindings_bdwgc_sys as gc; use nix_bindings_expr_sys as raw; use nix_bindings_store::path::StorePath; @@ -148,17 +147,13 @@ use std::ffi::{c_char, CString}; use std::iter::FromIterator; use std::os::raw::c_uint; use std::ptr::{null, null_mut, NonNull}; -use std::sync::{Arc, Weak}; +use std::sync::{Arc, LazyLock, Weak}; -lazy_static! { - static ref INIT: Result<()> = { - unsafe { - gc::GC_allow_register_threads(); - check_call!(raw::libexpr_init(&mut Context::new()))?; - Ok(()) - } - }; -} +static INIT: LazyLock> = LazyLock::new(|| unsafe { + gc::GC_allow_register_threads(); + check_call!(raw::libexpr_init(&mut Context::new()))?; + Ok(()) +}); pub fn init() -> Result<()> { let x = INIT.as_ref(); diff --git a/nix-bindings-flake/Cargo.toml b/nix-bindings-flake/Cargo.toml index 5222133..336b1f8 100644 --- a/nix-bindings-flake/Cargo.toml +++ b/nix-bindings-flake/Cargo.toml @@ -17,7 +17,6 @@ nix-bindings-fetchers = { path = "../nix-bindings-fetchers", version = "0.2.1" } nix-bindings-store = { path = "../nix-bindings-store", version = "0.2.1" } nix-bindings-util = { path = "../nix-bindings-util", version = "0.2.1" } nix-bindings-flake-sys = { path = "../nix-bindings-flake-sys", version = "0.2.1" } -lazy_static = "1.4" ctor = "0.2" tempfile = "3.10" cstr = "0.2" diff --git a/nix-bindings-store/Cargo.toml b/nix-bindings-store/Cargo.toml index 232688b..83aab99 100644 --- a/nix-bindings-store/Cargo.toml +++ b/nix-bindings-store/Cargo.toml @@ -16,7 +16,6 @@ anyhow = "1.0" nix-bindings-util = { path = "../nix-bindings-util", version = "0.2.1" } nix-bindings-util-sys = { path = "../nix-bindings-util-sys", version = "0.2.1" } nix-bindings-store-sys = { path = "../nix-bindings-store-sys", version = "0.2.1" } -lazy_static = "1.4" zerocopy = "0.8" harmonia-store-core = { version = "0.0.0-alpha.0", optional = true } serde_json = { version = "1.0", optional = true } diff --git a/nix-bindings-store/src/store.rs b/nix-bindings-store/src/store.rs index 7f231f0..655a088 100644 --- a/nix-bindings-store/src/store.rs +++ b/nix-bindings-store/src/store.rs @@ -1,5 +1,4 @@ use anyhow::{bail, Error, Result}; -use lazy_static::lazy_static; use nix_bindings_store_sys as raw; use nix_bindings_util::context::Context; use nix_bindings_util::string_return::{ @@ -13,19 +12,17 @@ use std::collections::HashMap; use std::ffi::{c_char, CString}; use std::ptr::null_mut; use std::ptr::NonNull; -use std::sync::{Arc, Mutex, Weak}; +use std::sync::{Arc, LazyLock, Mutex, Weak}; #[cfg(nix_at_least = "2.33.0pre")] use crate::derivation::Derivation; use crate::path::StorePath; /* TODO make Nix itself thread safe */ -lazy_static! { - static ref INIT: Result<()> = unsafe { - check_call!(raw::libstore_init(&mut Context::new()))?; - Ok(()) - }; -} +static INIT: LazyLock> = LazyLock::new(|| unsafe { + check_call!(raw::libstore_init(&mut Context::new()))?; + Ok(()) +}); struct StoreRef { inner: NonNull, @@ -68,9 +65,8 @@ impl StoreWeak { /// Protects against https://github.com/NixOS/nix/issues/11979 (unless different parameters are passed, in which case it's up to luck, but you do get your own parameters as you asked for). type StoreCacheMap = HashMap<(Option, Vec<(String, String)>), StoreWeak>; -lazy_static! { - static ref STORE_CACHE: Arc> = Arc::new(Mutex::new(HashMap::new())); -} +static STORE_CACHE: LazyLock>> = + LazyLock::new(|| Arc::new(Mutex::new(HashMap::new()))); #[cfg(nix_at_least = "2.33.0pre")] unsafe extern "C" fn callback_get_result_store_path_set(