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
18
rust/nix-flake/Cargo.toml
Normal file
18
rust/nix-flake/Cargo.toml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
[package]
|
||||
name = "nix-flake"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.79"
|
||||
nix-expr = { path = "../nix-expr" }
|
||||
nix-store = { path = "../nix-store" }
|
||||
nix-util = { path = "../nix-util" }
|
||||
nix-c-raw = { path = "../nix-c-raw" }
|
||||
lazy_static = "1.4.0"
|
||||
ctor = "0.2.7"
|
||||
tempfile = "3.10.1"
|
||||
cstr = "0.2.12"
|
||||
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