nixide/rust/nix-flake/src/lib.rs
Robert Hensing d40bbbed88 maint: Update Nix
(cherry picked from commit 203f5d519369235097fef2bdaefa6b3d0f5e963b)
2025-10-04 02:31:16 +02:00

26 lines
717 B
Rust

use anyhow::Result;
use nix_c_raw as raw;
use nix_util::context::{self, Context};
pub struct FlakeSettings {
pub(crate) ptr: *mut raw::flake_settings,
}
impl Drop for FlakeSettings {
fn drop(&mut self) {
unsafe {
raw::flake_settings_free(self.ptr);
}
}
}
impl FlakeSettings {
pub fn new() -> Result<Self> {
let mut ctx = Context::new();
let s = unsafe { context::check_call!(raw::flake_settings_new(&mut ctx)) }?;
Ok(FlakeSettings { ptr: s })
}
pub fn init_globally(&mut self) -> Result<()> {
let mut ctx = Context::new();
unsafe { context::check_call!(raw::flake_init_global(&mut ctx, self.ptr)) }?;
Ok(())
}
}