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
8
flake.lock
generated
8
flake.lock
generated
|
|
@ -156,17 +156,17 @@
|
|||
"pre-commit-hooks": "pre-commit-hooks"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1719448136,
|
||||
"narHash": "sha256-ya0iofP+QysNzN7Gx7Btfe83ZW1YLpSdkccUNMnbBFQ=",
|
||||
"lastModified": 1732892090,
|
||||
"narHash": "sha256-Ka/uNdaqpTAiVL++4MPHg8fG5o1tiJeY6G2t5UiKhd8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nix",
|
||||
"rev": "ed129267dcd7dd2cce48c09b17aefd6cfc488bcd",
|
||||
"rev": "64000481168d1da9d2519f055dd1fdee22275c21",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "master",
|
||||
"repo": "nix",
|
||||
"rev": "ed129267dcd7dd2cce48c09b17aefd6cfc488bcd",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
inputs = {
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
nix.url = "github:NixOS/nix/ed129267dcd7dd2cce48c09b17aefd6cfc488bcd"; # 2.24-pre, before splitting libnixflake
|
||||
nix.url = "github:NixOS/nix/master";
|
||||
nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
nix-cargo-integration.url = "github:yusdacra/nix-cargo-integration";
|
||||
nix-cargo-integration.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
|
|
|||
15
rust/Cargo.lock
generated
15
rust/Cargo.lock
generated
|
|
@ -323,6 +323,21 @@ dependencies = [
|
|||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix-flake"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cstr",
|
||||
"ctor",
|
||||
"lazy_static",
|
||||
"nix-c-raw",
|
||||
"nix-expr",
|
||||
"nix-store",
|
||||
"nix-util",
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix-store"
|
||||
version = "0.1.0"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
[workspace]
|
||||
members = [
|
||||
"nix-c-raw",
|
||||
"nix-flake",
|
||||
"nix-expr",
|
||||
"nix-util",
|
||||
"nix-store",
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ impl bindgen::callbacks::ParseCallbacks for StripNixPrefix {
|
|||
fn main() {
|
||||
// Tell cargo to invalidate the built crate whenever the wrapper changes
|
||||
println!("cargo:rerun-if-changed=include/nix-c-raw.h");
|
||||
// println!("cargo:rustc-link-lib=nixflake");
|
||||
println!("cargo:rustc-link-lib=nixflake");
|
||||
|
||||
// https://rust-lang.github.io/rust-bindgen/library-usage.html
|
||||
let bindings = bindgen::Builder::default()
|
||||
|
|
@ -39,7 +39,7 @@ fn main() {
|
|||
fn c_headers() -> Vec<String> {
|
||||
let mut args = Vec::new();
|
||||
// args.push("-isystem".to_string());
|
||||
for path in pkg_config::probe_library("nix-expr-c")
|
||||
for path in pkg_config::probe_library("nix-flake-c")
|
||||
.unwrap()
|
||||
.include_paths
|
||||
.iter()
|
||||
|
|
|
|||
|
|
@ -4,3 +4,4 @@
|
|||
#include <gc/gc.h>
|
||||
#include <nix_api_expr.h>
|
||||
#include <nix_api_value.h>
|
||||
#include <nix_api_flake.h>
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ unsafe extern "C" fn function_adapter(
|
|||
CString::new("<rust nix-expr application error message contained null byte>")
|
||||
.unwrap()
|
||||
});
|
||||
raw::set_err_msg(context_out, raw::NIX_ERR_UNKNOWN, cstr.as_ptr());
|
||||
raw::set_err_msg(context_out, raw::err_NIX_ERR_UNKNOWN, cstr.as_ptr());
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
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(())
|
||||
}
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@ impl Context {
|
|||
/// We recommend to use `check_call!` if possible.
|
||||
pub fn check_err(&self) -> Result<()> {
|
||||
let err = unsafe { raw::err_code(self.inner.as_ptr()) };
|
||||
if err != raw::NIX_OK.try_into().unwrap() {
|
||||
if err != raw::err_NIX_OK.try_into().unwrap() {
|
||||
// msgp is a borrowed pointer (pointing into the context), so we don't need to free it
|
||||
let msgp = unsafe { raw::err_msg(null_mut(), self.inner.as_ptr(), null_mut()) };
|
||||
// Turn the i8 pointer into a Rust string by copying
|
||||
|
|
@ -50,7 +50,7 @@ impl Context {
|
|||
unsafe {
|
||||
raw::set_err_msg(
|
||||
self.inner.as_ptr(),
|
||||
raw::NIX_OK.try_into().unwrap(),
|
||||
raw::err_NIX_OK.try_into().unwrap(),
|
||||
b"\0".as_ptr() as *const i8,
|
||||
);
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ impl Context {
|
|||
f: F,
|
||||
) -> Result<Option<T>> {
|
||||
let t = f(self.ptr());
|
||||
if unsafe { raw::err_code(self.inner.as_ptr()) == raw::NIX_ERR_KEY } {
|
||||
if unsafe { raw::err_code(self.inner.as_ptr()) == raw::err_NIX_ERR_KEY } {
|
||||
self.clear();
|
||||
return Ok(None);
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ macro_rules! check_call_opt_key {
|
|||
{
|
||||
let ctx : &mut $crate::context::Context = $ctx;
|
||||
let ret = $($f)::*(ctx.ptr(), $($arg,)*);
|
||||
if unsafe { raw::err_code(ctx.ptr()) == raw::NIX_ERR_KEY } {
|
||||
if unsafe { raw::err_code(ctx.ptr()) == raw::err_NIX_ERR_KEY } {
|
||||
ctx.clear();
|
||||
return Ok(None);
|
||||
}
|
||||
|
|
@ -143,7 +143,7 @@ mod tests {
|
|||
unsafe {
|
||||
raw::set_err_msg(
|
||||
ctx_ptr,
|
||||
raw::NIX_ERR_UNKNOWN.try_into().unwrap(),
|
||||
raw::err_NIX_ERR_UNKNOWN.try_into().unwrap(),
|
||||
b"dummy error message\0".as_ptr() as *const i8,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue