support nix_flake_settings extensions

This commit is contained in:
do butterflies cry? 2026-04-10 12:55:56 +10:00
parent e3c315050f
commit 38a8128d32
Signed by: cry
GPG key ID: F68745A836CA0412

View file

@ -2,6 +2,7 @@ use std::ptr::NonNull;
use crate::NixideResult;
use crate::errors::ErrorContext;
use crate::stdext::AsCPtr as _;
use crate::sys;
use crate::util::wrap;
use crate::util::wrappers::AsInnerPtr;
@ -44,4 +45,57 @@ impl FlakeSettings {
Ok(Self { inner })
}
/// # Nix C API Internals
///
/// This binding is **not provided by the Nix C API.**
/// It is instead **exposed by the Nixide C API extensions.**
///
#[allow(unused)]
pub fn use_registries(self, value: bool) -> Self {
wrap::nix_fn!(|ctx: &ErrorContext| unsafe {
sys::nix_flake_settings_set_use_registries(ctx.as_ptr(), self.as_ptr(), value)
})
.unwrap();
self
}
/// # Nix C API Internals
///
/// This binding is **not provided by the Nix C API.**
/// It is instead **exposed by the Nixide C API extensions.**
///
#[allow(unused)]
pub fn accept_flake_config(self, value: bool) -> Self {
wrap::nix_fn!(|ctx: &ErrorContext| unsafe {
sys::nix_flake_settings_set_accept_flake_config(ctx.as_ptr(), self.as_ptr(), value)
})
.unwrap();
self
}
/// # Errors
/// Fails if the given `path` contains a NUL byte.
///
/// # Nix C API Internals
///
/// This binding is **not provided by the Nix C API.**
/// It is instead **exposed by the Nixide C API extensions.**
///
#[allow(unused)]
pub fn commit_lock_file_summary(self, summary: &str) -> NixideResult<Self> {
let summary_ptr = summary.into_c_ptr()?;
wrap::nix_fn!(|ctx: &ErrorContext| unsafe {
sys::nix_flake_settings_set_commit_lock_file_summary(
ctx.as_ptr(),
self.as_ptr(),
summary_ptr,
)
})
.unwrap();
Ok(self)
}
}