Rename crates nix- -> nix-bindings-
This way, the crates can be published without interfering with potential future non-bindings `nix-` crates, if Nix proper wants to have native rust code, for instance.
This commit is contained in:
parent
4b13929db3
commit
b3171585d1
30 changed files with 209 additions and 1853 deletions
1804
rust/Cargo.lock
generated
1804
rust/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,10 +1,10 @@
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
"nix-c-raw",
|
"nix-bindings-bindgen-raw",
|
||||||
"nix-expr",
|
"nix-bindings-expr",
|
||||||
"nix-fetchers",
|
"nix-bindings-fetchers",
|
||||||
"nix-flake",
|
"nix-bindings-flake",
|
||||||
"nix-store",
|
"nix-bindings-store",
|
||||||
"nix-util",
|
"nix-bindings-util",
|
||||||
]
|
]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "nix-c-raw"
|
name = "nix-bindings-bindgen-raw"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
# nix-c-raw
|
# nix-bindings-bindgen-raw
|
||||||
|
|
||||||
This crate contains generated bindings for the Nix C API.
|
This crate contains generated bindings for the Nix C API.
|
||||||
**You should not have to use this crate directly,** and so you should probably not add it to your dependencies.
|
**You should not have to use this crate directly,** and so you should probably not add it to your dependencies.
|
||||||
Instead, use the `nix-util`, `nix-store` and `nix-expr` crates, which _should_ be sufficient.
|
Instead, use the `nix-bindings-util`, `nix-bindings-store` and `nix-bindings-expr` crates, which _should_ be sufficient.
|
||||||
|
|
||||||
## Design
|
## Design
|
||||||
|
|
||||||
18
rust/nix-bindings-expr/Cargo.toml
Normal file
18
rust/nix-bindings-expr/Cargo.toml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
[package]
|
||||||
|
name = "nix-bindings-expr"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
license = "LGPL-2.1"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/lib.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow = "1.0"
|
||||||
|
nix-bindings-store = { path = "../nix-bindings-store" }
|
||||||
|
nix-bindings-util = { path = "../nix-bindings-util" }
|
||||||
|
nix-bindings-bindgen-raw = { path = "../nix-bindings-bindgen-raw" }
|
||||||
|
lazy_static = "1.4"
|
||||||
|
ctor = "0.2"
|
||||||
|
tempfile = "3.10"
|
||||||
|
cstr = "0.2"
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
//! Create an [`EvalState`] using [`EvalState::new`] or [`EvalStateBuilder`] for advanced configuration:
|
//! Create an [`EvalState`] using [`EvalState::new`] or [`EvalStateBuilder`] for advanced configuration:
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! # use nix_expr::eval_state::{EvalState, EvalStateBuilder, test_init, gc_register_my_thread};
|
//! # use nix_bindings_expr::eval_state::{EvalState, EvalStateBuilder, test_init, gc_register_my_thread};
|
||||||
//! # use nix_store::store::Store;
|
//! # use nix_bindings_store::store::Store;
|
||||||
//! # use std::collections::HashMap;
|
//! # use std::collections::HashMap;
|
||||||
//! # fn example() -> anyhow::Result<()> {
|
//! # fn example() -> anyhow::Result<()> {
|
||||||
//! # test_init(); let guard = gc_register_my_thread()?;
|
//! # test_init(); let guard = gc_register_my_thread()?;
|
||||||
|
|
@ -71,7 +71,7 @@
|
||||||
//! Before using [`EvalState`] in a thread, register it with the (process memory) garbage collector:
|
//! Before using [`EvalState`] in a thread, register it with the (process memory) garbage collector:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! # use nix_expr::eval_state::{init, gc_register_my_thread, test_init};
|
//! # use nix_bindings_expr::eval_state::{init, gc_register_my_thread, test_init};
|
||||||
//! # fn example() -> anyhow::Result<()> {
|
//! # fn example() -> anyhow::Result<()> {
|
||||||
//! # test_init(); // Use test_init() in tests
|
//! # test_init(); // Use test_init() in tests
|
||||||
//! init()?; // Initialize Nix library
|
//! init()?; // Initialize Nix library
|
||||||
|
|
@ -92,8 +92,8 @@
|
||||||
//! ## Examples
|
//! ## Examples
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use nix_expr::eval_state::{EvalState, test_init, gc_register_my_thread};
|
//! use nix_bindings_expr::eval_state::{EvalState, test_init, gc_register_my_thread};
|
||||||
//! use nix_store::store::Store;
|
//! use nix_bindings_store::store::Store;
|
||||||
//! use std::collections::HashMap;
|
//! use std::collections::HashMap;
|
||||||
//!
|
//!
|
||||||
//! # fn main() -> anyhow::Result<()> {
|
//! # fn main() -> anyhow::Result<()> {
|
||||||
|
|
@ -134,12 +134,12 @@ use anyhow::Context as _;
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
use cstr::cstr;
|
use cstr::cstr;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use nix_c_raw as raw;
|
use nix_bindings_bindgen_raw as raw;
|
||||||
use nix_store::path::StorePath;
|
use nix_bindings_store::path::StorePath;
|
||||||
use nix_store::store::{Store, StoreWeak};
|
use nix_bindings_store::store::{Store, StoreWeak};
|
||||||
use nix_util::context::Context;
|
use nix_bindings_util::context::Context;
|
||||||
use nix_util::string_return::{callback_get_result_string, callback_get_result_string_data};
|
use nix_bindings_util::string_return::{callback_get_result_string, callback_get_result_string_data};
|
||||||
use nix_util::{check_call, check_call_opt_key, result_string_init};
|
use nix_bindings_util::{check_call, check_call_opt_key, result_string_init};
|
||||||
use std::ffi::{c_char, CString};
|
use std::ffi::{c_char, CString};
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
use std::os::raw::c_uint;
|
use std::os::raw::c_uint;
|
||||||
|
|
@ -162,7 +162,7 @@ pub fn init() -> Result<()> {
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
// Couldn't just clone the error, so we have to print it here.
|
// Couldn't just clone the error, so we have to print it here.
|
||||||
Err(anyhow::format_err!("nix_expr::init error: {}", e))
|
Err(anyhow::format_err!("nix_bindings_expr::init error: {}", e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -225,8 +225,8 @@ impl Drop for EvalStateRef {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use nix_expr::eval_state::{EvalState, EvalStateBuilder, test_init, gc_register_my_thread};
|
/// # use nix_bindings_expr::eval_state::{EvalState, EvalStateBuilder, test_init, gc_register_my_thread};
|
||||||
/// # use nix_store::store::Store;
|
/// # use nix_bindings_store::store::Store;
|
||||||
/// # use std::collections::HashMap;
|
/// # use std::collections::HashMap;
|
||||||
/// # fn example() -> anyhow::Result<()> {
|
/// # fn example() -> anyhow::Result<()> {
|
||||||
/// # test_init();
|
/// # test_init();
|
||||||
|
|
@ -369,9 +369,9 @@ impl EvalState {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use nix_expr::eval_state::{EvalState, test_init, gc_register_my_thread};
|
/// # use nix_bindings_expr::eval_state::{EvalState, test_init, gc_register_my_thread};
|
||||||
/// use nix_store::store::Store;
|
/// use nix_bindings_store::store::Store;
|
||||||
/// use nix_expr::value::Value;
|
/// use nix_bindings_expr::value::Value;
|
||||||
/// use std::collections::HashMap;
|
/// use std::collections::HashMap;
|
||||||
///
|
///
|
||||||
/// # fn main() -> anyhow::Result<()> {
|
/// # fn main() -> anyhow::Result<()> {
|
||||||
|
|
@ -474,8 +474,8 @@ impl EvalState {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use nix_expr::eval_state::{EvalState, test_init, gc_register_my_thread};
|
/// # use nix_bindings_expr::eval_state::{EvalState, test_init, gc_register_my_thread};
|
||||||
/// # use nix_store::store::Store;
|
/// # use nix_bindings_store::store::Store;
|
||||||
/// # use std::collections::HashMap;
|
/// # use std::collections::HashMap;
|
||||||
/// # fn example() -> anyhow::Result<()> {
|
/// # fn example() -> anyhow::Result<()> {
|
||||||
/// # test_init();
|
/// # test_init();
|
||||||
|
|
@ -529,9 +529,9 @@ impl EvalState {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// # use nix_expr::value::Value;
|
/// # use nix_bindings_expr::value::Value;
|
||||||
/// # use std::collections::{VecDeque, LinkedList};
|
/// # use std::collections::{VecDeque, LinkedList};
|
||||||
/// # fn example(es: &mut nix_expr::eval_state::EvalState, list_value: &Value) -> anyhow::Result<()> {
|
/// # fn example(es: &mut nix_bindings_expr::eval_state::EvalState, list_value: &Value) -> anyhow::Result<()> {
|
||||||
/// let vec: Vec<Value> = es.require_list_strict(&list_value)?;
|
/// let vec: Vec<Value> = es.require_list_strict(&list_value)?;
|
||||||
/// let deque: VecDeque<Value> = es.require_list_strict(&list_value)?;
|
/// let deque: VecDeque<Value> = es.require_list_strict(&list_value)?;
|
||||||
/// let linked_list = es.require_list_strict::<LinkedList<Value>>(&list_value)?;
|
/// let linked_list = es.require_list_strict::<LinkedList<Value>>(&list_value)?;
|
||||||
|
|
@ -942,8 +942,8 @@ impl EvalState {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use nix_expr::eval_state::{EvalState, test_init, gc_register_my_thread};
|
/// # use nix_bindings_expr::eval_state::{EvalState, test_init, gc_register_my_thread};
|
||||||
/// # use nix_store::store::Store;
|
/// # use nix_bindings_store::store::Store;
|
||||||
/// # use std::collections::HashMap;
|
/// # use std::collections::HashMap;
|
||||||
/// # fn example() -> anyhow::Result<()> {
|
/// # fn example() -> anyhow::Result<()> {
|
||||||
/// # test_init();
|
/// # test_init();
|
||||||
|
|
@ -1043,8 +1043,8 @@ impl EvalState {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// # use nix_expr::eval_state::{EvalState, test_init, gc_register_my_thread};
|
/// # use nix_bindings_expr::eval_state::{EvalState, test_init, gc_register_my_thread};
|
||||||
/// # use nix_store::store::Store;
|
/// # use nix_bindings_store::store::Store;
|
||||||
/// # use std::collections::HashMap;
|
/// # use std::collections::HashMap;
|
||||||
/// # fn example() -> anyhow::Result<()> {
|
/// # fn example() -> anyhow::Result<()> {
|
||||||
/// # test_init();
|
/// # test_init();
|
||||||
|
|
@ -1211,18 +1211,18 @@ pub fn test_init() {
|
||||||
// would cause the test suite to reinvokes itself, causing an infinite loop.
|
// would cause the test suite to reinvokes itself, causing an infinite loop.
|
||||||
// While _NIX_TEST_NO_SANDBOX=1 should prevent this, we may also set the
|
// While _NIX_TEST_NO_SANDBOX=1 should prevent this, we may also set the
|
||||||
// build hook to "" to prevent this.
|
// build hook to "" to prevent this.
|
||||||
nix_util::settings::set("build-hook", "").unwrap();
|
nix_bindings_util::settings::set("build-hook", "").unwrap();
|
||||||
|
|
||||||
// When testing in the sandbox, the default build dir would be a parent of the storeDir,
|
// When testing in the sandbox, the default build dir would be a parent of the storeDir,
|
||||||
// which causes an error. So we set a custom build dir here.
|
// which causes an error. So we set a custom build dir here.
|
||||||
// Only available on linux
|
// Only available on linux
|
||||||
if cfg!(target_os = "linux") {
|
if cfg!(target_os = "linux") {
|
||||||
nix_util::settings::set("sandbox-build-dir", "/custom-build-dir-for-test").unwrap();
|
nix_bindings_util::settings::set("sandbox-build-dir", "/custom-build-dir-for-test").unwrap();
|
||||||
}
|
}
|
||||||
std::env::set_var("_NIX_TEST_NO_SANDBOX", "1");
|
std::env::set_var("_NIX_TEST_NO_SANDBOX", "1");
|
||||||
|
|
||||||
// The tests run offline
|
// The tests run offline
|
||||||
nix_util::settings::set("substituters", "").unwrap();
|
nix_bindings_util::settings::set("substituters", "").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::eval_state::{EvalState, EvalStateWeak};
|
use crate::eval_state::{EvalState, EvalStateWeak};
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use nix_c_raw as raw;
|
use nix_bindings_bindgen_raw as raw;
|
||||||
use nix_util::check_call;
|
use nix_bindings_util::check_call;
|
||||||
use std::ffi::{c_int, c_void, CStr, CString};
|
use std::ffi::{c_int, c_void, CStr, CString};
|
||||||
use std::mem::ManuallyDrop;
|
use std::mem::ManuallyDrop;
|
||||||
use std::ptr::{null, null_mut};
|
use std::ptr::{null, null_mut};
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
pub mod __private;
|
pub mod __private;
|
||||||
|
|
||||||
use nix_c_raw as raw;
|
use nix_bindings_bindgen_raw as raw;
|
||||||
use nix_util::{check_call, context::Context};
|
use nix_bindings_util::{check_call, context::Context};
|
||||||
use std::ptr::{null_mut, NonNull};
|
use std::ptr::{null_mut, NonNull};
|
||||||
|
|
||||||
// TODO: test: cloning a thunk does not duplicate the evaluation.
|
// TODO: test: cloning a thunk does not duplicate the evaluation.
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
//! Functions that are relevant for other bindings modules, but normally not end users.
|
//! Functions that are relevant for other bindings modules, but normally not end users.
|
||||||
use super::Value;
|
use super::Value;
|
||||||
use nix_c_raw as raw;
|
use nix_bindings_bindgen_raw as raw;
|
||||||
|
|
||||||
/// See [Value::new].
|
/// See [Value::new].
|
||||||
pub unsafe fn raw_value_new(ptr: *mut raw::Value) -> Value {
|
pub unsafe fn raw_value_new(ptr: *mut raw::Value) -> Value {
|
||||||
17
rust/nix-bindings-fetchers/Cargo.toml
Normal file
17
rust/nix-bindings-fetchers/Cargo.toml
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
[package]
|
||||||
|
name = "nix-bindings-fetchers"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
license = "LGPL-2.1"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/lib.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow = "1.0"
|
||||||
|
nix-bindings-store = { path = "../nix-bindings-store" }
|
||||||
|
nix-bindings-util = { path = "../nix-bindings-util" }
|
||||||
|
nix-bindings-bindgen-raw = { path = "../nix-bindings-bindgen-raw" }
|
||||||
|
ctor = "0.2"
|
||||||
|
tempfile = "3.10"
|
||||||
|
cstr = "0.2"
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use anyhow::{Context as _, Result};
|
use anyhow::{Context as _, Result};
|
||||||
use nix_c_raw as raw;
|
use nix_bindings_bindgen_raw as raw;
|
||||||
use nix_util::context::{self, Context};
|
use nix_bindings_util::context::{self, Context};
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
pub struct FetchersSettings {
|
pub struct FetchersSettings {
|
||||||
20
rust/nix-bindings-flake/Cargo.toml
Normal file
20
rust/nix-bindings-flake/Cargo.toml
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
[package]
|
||||||
|
name = "nix-bindings-flake"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
license = "LGPL-2.1"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/lib.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow = "1.0"
|
||||||
|
nix-bindings-expr = { path = "../nix-bindings-expr" }
|
||||||
|
nix-bindings-fetchers = { path = "../nix-bindings-fetchers" }
|
||||||
|
nix-bindings-store = { path = "../nix-bindings-store" }
|
||||||
|
nix-bindings-util = { path = "../nix-bindings-util" }
|
||||||
|
nix-bindings-bindgen-raw = { path = "../nix-bindings-bindgen-raw" }
|
||||||
|
lazy_static = "1.4"
|
||||||
|
ctor = "0.2"
|
||||||
|
tempfile = "3.10"
|
||||||
|
cstr = "0.2"
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
use std::{ffi::CString, os::raw::c_char, ptr::NonNull};
|
use std::{ffi::CString, os::raw::c_char, ptr::NonNull};
|
||||||
|
|
||||||
use anyhow::{Context as _, Result};
|
use anyhow::{Context as _, Result};
|
||||||
use nix_c_raw as raw;
|
use nix_bindings_bindgen_raw as raw;
|
||||||
use nix_expr::eval_state::EvalState;
|
use nix_bindings_expr::eval_state::EvalState;
|
||||||
use nix_fetchers::FetchersSettings;
|
use nix_bindings_fetchers::FetchersSettings;
|
||||||
use nix_util::{
|
use nix_bindings_util::{
|
||||||
context::{self, Context},
|
context::{self, Context},
|
||||||
result_string_init,
|
result_string_init,
|
||||||
string_return::{callback_get_result_string, callback_get_result_string_data},
|
string_return::{callback_get_result_string, callback_get_result_string_data},
|
||||||
|
|
@ -29,7 +29,7 @@ impl FlakeSettings {
|
||||||
}
|
}
|
||||||
fn add_to_eval_state_builder(
|
fn add_to_eval_state_builder(
|
||||||
&self,
|
&self,
|
||||||
builder: &mut nix_expr::eval_state::EvalStateBuilder,
|
builder: &mut nix_bindings_expr::eval_state::EvalStateBuilder,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut ctx = Context::new();
|
let mut ctx = Context::new();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
@ -45,14 +45,14 @@ impl FlakeSettings {
|
||||||
|
|
||||||
pub trait EvalStateBuilderExt {
|
pub trait EvalStateBuilderExt {
|
||||||
/// Configures the eval state to provide flakes features such as `builtins.getFlake`.
|
/// Configures the eval state to provide flakes features such as `builtins.getFlake`.
|
||||||
fn flakes(self, settings: &FlakeSettings) -> Result<nix_expr::eval_state::EvalStateBuilder>;
|
fn flakes(self, settings: &FlakeSettings) -> Result<nix_bindings_expr::eval_state::EvalStateBuilder>;
|
||||||
}
|
}
|
||||||
impl EvalStateBuilderExt for nix_expr::eval_state::EvalStateBuilder {
|
impl EvalStateBuilderExt for nix_bindings_expr::eval_state::EvalStateBuilder {
|
||||||
/// Configures the eval state to provide flakes features such as `builtins.getFlake`.
|
/// Configures the eval state to provide flakes features such as `builtins.getFlake`.
|
||||||
fn flakes(
|
fn flakes(
|
||||||
mut self,
|
mut self,
|
||||||
settings: &FlakeSettings,
|
settings: &FlakeSettings,
|
||||||
) -> Result<nix_expr::eval_state::EvalStateBuilder> {
|
) -> Result<nix_bindings_expr::eval_state::EvalStateBuilder> {
|
||||||
settings.add_to_eval_state_builder(&mut self)?;
|
settings.add_to_eval_state_builder(&mut self)?;
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
@ -239,7 +239,7 @@ impl LockedFlake {
|
||||||
&self,
|
&self,
|
||||||
flake_settings: &FlakeSettings,
|
flake_settings: &FlakeSettings,
|
||||||
eval_state: &mut EvalState,
|
eval_state: &mut EvalState,
|
||||||
) -> Result<nix_expr::value::Value> {
|
) -> Result<nix_bindings_expr::value::Value> {
|
||||||
let mut ctx = Context::new();
|
let mut ctx = Context::new();
|
||||||
unsafe {
|
unsafe {
|
||||||
let r = context::check_call!(raw::locked_flake_get_output_attrs(
|
let r = context::check_call!(raw::locked_flake_get_output_attrs(
|
||||||
|
|
@ -248,15 +248,15 @@ impl LockedFlake {
|
||||||
eval_state.raw_ptr(),
|
eval_state.raw_ptr(),
|
||||||
self.ptr.as_ptr()
|
self.ptr.as_ptr()
|
||||||
))?;
|
))?;
|
||||||
Ok(nix_expr::value::__private::raw_value_new(r))
|
Ok(nix_bindings_expr::value::__private::raw_value_new(r))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use nix_expr::eval_state::{gc_register_my_thread, EvalStateBuilder};
|
use nix_bindings_expr::eval_state::{gc_register_my_thread, EvalStateBuilder};
|
||||||
use nix_store::store::Store;
|
use nix_bindings_store::store::Store;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::sync::Once;
|
use std::sync::Once;
|
||||||
|
|
@ -267,7 +267,7 @@ mod tests {
|
||||||
// Only set experimental-features once to minimize the window where
|
// Only set experimental-features once to minimize the window where
|
||||||
// concurrent Nix operations might read the setting while it's being modified
|
// concurrent Nix operations might read the setting while it's being modified
|
||||||
INIT.call_once(|| {
|
INIT.call_once(|| {
|
||||||
nix_util::settings::set("experimental-features", "flakes").unwrap();
|
nix_bindings_util::settings::set("experimental-features", "flakes").unwrap();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "nix-store"
|
name = "nix-bindings-store"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
@ -10,8 +10,8 @@ path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
nix-util = { path = "../nix-util" }
|
nix-bindings-util = { path = "../nix-bindings-util" }
|
||||||
nix-c-raw = { path = "../nix-c-raw" }
|
nix-bindings-bindgen-raw = { path = "../nix-bindings-bindgen-raw" }
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use nix_c_raw as raw;
|
use nix_bindings_bindgen_raw as raw;
|
||||||
use nix_util::{
|
use nix_bindings_util::{
|
||||||
result_string_init,
|
result_string_init,
|
||||||
string_return::{callback_get_result_string, callback_get_result_string_data},
|
string_return::{callback_get_result_string, callback_get_result_string_data},
|
||||||
};
|
};
|
||||||
|
|
@ -60,7 +60,7 @@ impl StorePath {
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// This function is unsafe because it returns a raw pointer. The caller must ensure that the pointer is not used beyond the lifetime of this `StorePath`.
|
/// This function is unsafe because it returns a raw pointer. The caller must ensure that the pointer is not used beyond the lifetime of this `StorePath`.
|
||||||
pub unsafe fn as_ptr(&self) -> *mut nix_c_raw::StorePath {
|
pub unsafe fn as_ptr(&self) -> *mut raw::StorePath {
|
||||||
self.raw.as_ptr()
|
self.raw.as_ptr()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use anyhow::{bail, Error, Result};
|
use anyhow::{bail, Error, Result};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use nix_c_raw as raw;
|
use nix_bindings_bindgen_raw as raw;
|
||||||
use nix_util::context::Context;
|
use nix_bindings_util::context::Context;
|
||||||
use nix_util::string_return::{callback_get_result_string, callback_get_result_string_data};
|
use nix_bindings_util::string_return::{callback_get_result_string, callback_get_result_string_data};
|
||||||
use nix_util::{check_call, result_string_init};
|
use nix_bindings_util::{check_call, result_string_init};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::ffi::{c_char, CString};
|
use std::ffi::{c_char, CString};
|
||||||
use std::ptr::null_mut;
|
use std::ptr::null_mut;
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "nix-util"
|
name = "nix-bindings-util"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "LGPL-2.1"
|
license = "LGPL-2.1"
|
||||||
|
|
@ -9,5 +9,5 @@ path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
nix-c-raw = { path = "../nix-c-raw" }
|
nix-bindings-bindgen-raw = { path = "../nix-bindings-bindgen-raw" }
|
||||||
ctor = "0.2"
|
ctor = "0.2"
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
use nix_c_raw as raw;
|
use nix_bindings_bindgen_raw as raw;
|
||||||
use std::os::raw::c_char;
|
use std::os::raw::c_char;
|
||||||
use std::ptr::null_mut;
|
use std::ptr::null_mut;
|
||||||
use std::ptr::NonNull;
|
use std::ptr::NonNull;
|
||||||
|
|
||||||
/// A context for error handling, when interacting directly with the generated bindings for the C API in [nix_c_raw].
|
/// A context for error handling, when interacting directly with the generated bindings for the C API in [nix_bindings_bindgen_raw].
|
||||||
///
|
///
|
||||||
/// The `nix-store` and `nix-expr` libraries that consume this type internally store a private context in their `EvalState` and `Store` structs to avoid allocating a new context for each operation. The state of a context is irrelevant when used correctly (e.g. with [check_call!]), so it's safe to reuse, and safe to allocate more contexts in methods such as [Clone::clone].
|
/// The `nix-store` and `nix-expr` libraries that consume this type internally store a private context in their `EvalState` and `Store` structs to avoid allocating a new context for each operation. The state of a context is irrelevant when used correctly (e.g. with [check_call!]), so it's safe to reuse, and safe to allocate more contexts in methods such as [Clone::clone].
|
||||||
pub struct Context {
|
pub struct Context {
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use nix_c_raw as raw;
|
use nix_bindings_bindgen_raw as raw;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
@ -52,9 +52,9 @@ macro_rules! result_string_init {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use nix_c_raw as raw;
|
use nix_bindings_bindgen_raw as raw;
|
||||||
|
|
||||||
/// Typecheck the function signature against the generated bindings in nix_c_raw.
|
/// Typecheck the function signature against the generated bindings in nix_bindings_bindgen_raw.
|
||||||
static _CALLBACK_GET_RESULT_STRING: raw::get_string_callback = Some(callback_get_result_string);
|
static _CALLBACK_GET_RESULT_STRING: raw::get_string_callback = Some(callback_get_result_string);
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "nix-expr"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
license = "LGPL-2.1"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
path = "src/lib.rs"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
anyhow = "1.0"
|
|
||||||
nix-store = { path = "../nix-store" }
|
|
||||||
nix-util = { path = "../nix-util" }
|
|
||||||
nix-c-raw = { path = "../nix-c-raw" }
|
|
||||||
lazy_static = "1.4"
|
|
||||||
ctor = "0.2"
|
|
||||||
tempfile = "3.10"
|
|
||||||
cstr = "0.2"
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "nix-fetchers"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
license = "LGPL-2.1"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
path = "src/lib.rs"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
anyhow = "1.0"
|
|
||||||
nix-store = { path = "../nix-store" }
|
|
||||||
nix-util = { path = "../nix-util" }
|
|
||||||
nix-c-raw = { path = "../nix-c-raw" }
|
|
||||||
ctor = "0.2"
|
|
||||||
tempfile = "3.10"
|
|
||||||
cstr = "0.2"
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "nix-flake"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
license = "LGPL-2.1"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
path = "src/lib.rs"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
anyhow = "1.0"
|
|
||||||
nix-expr = { path = "../nix-expr" }
|
|
||||||
nix-fetchers = { path = "../nix-fetchers" }
|
|
||||||
nix-store = { path = "../nix-store" }
|
|
||||||
nix-util = { path = "../nix-util" }
|
|
||||||
nix-c-raw = { path = "../nix-c-raw" }
|
|
||||||
lazy_static = "1.4"
|
|
||||||
ctor = "0.2"
|
|
||||||
tempfile = "3.10"
|
|
||||||
cstr = "0.2"
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue