maint: Update Nix
(cherry picked from commit 203f5d519369235097fef2bdaefa6b3d0f5e963b)
This commit is contained in:
parent
676120cd6a
commit
d40bbbed88
10 changed files with 74 additions and 13 deletions
26
rust/nix-flake/src/lib.rs
Normal file
26
rust/nix-flake/src/lib.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
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(())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue