fix: Temporarily revert Nix to recover getFlake

https://github.com/NixOS/nix/issues/11399
(cherry picked from commit 0f2ae7d080dda34938517f781b4eb436522e9d65)
This commit is contained in:
Robert Hensing 2024-09-02 14:25:31 +02:00
parent 9213c9a5a0
commit 69d4ccc422
5 changed files with 48 additions and 47 deletions

80
flake.lock generated
View file

@ -95,50 +95,18 @@
"type": "github"
}
},
"git-hooks-nix": {
"inputs": {
"flake-compat": [
"nix"
],
"gitignore": [
"nix"
],
"nixpkgs": [
"nix",
"nixpkgs"
],
"nixpkgs-stable": [
"nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1721042469,
"narHash": "sha256-6FPUl7HVtvRHCCBQne7Ylp4p+dpP3P/OYuzjztZ4s70=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "f451c19376071a90d8c58ab1a953c6e9840527fd",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"libgit2": {
"flake": false,
"locked": {
"lastModified": 1715853528,
"narHash": "sha256-J2rCxTecyLbbDdsyBWn9w7r3pbKRMkI9E7RvRgAqBdY=",
"lastModified": 1724328629,
"narHash": "sha256-7SuD4k+ORwFPwDm5Qr5eSV6GMVWjMfFed9KYi8riUQo=",
"owner": "libgit2",
"repo": "libgit2",
"rev": "36f7e21ad757a3dacc58cf7944329da6bc1d6e96",
"rev": "782e29c906f6e44b120843356f286b6a97d89f88",
"type": "github"
},
"original": {
"owner": "libgit2",
"ref": "v1.8.1",
"repo": "libgit2",
"type": "github"
}
@ -163,25 +131,26 @@
"inputs": {
"flake-compat": "flake-compat",
"flake-parts": "flake-parts_2",
"git-hooks-nix": "git-hooks-nix",
"libgit2": "libgit2",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-23-11": "nixpkgs-23-11",
"nixpkgs-regression": "nixpkgs-regression"
"nixpkgs-regression": "nixpkgs-regression",
"pre-commit-hooks": "pre-commit-hooks"
},
"locked": {
"lastModified": 1724439434,
"narHash": "sha256-3+UgAktTtkGUNpxMxr+q+R+z3r026L3PwJzG6RD2IXM=",
"lastModified": 1719448136,
"narHash": "sha256-ya0iofP+QysNzN7Gx7Btfe83ZW1YLpSdkccUNMnbBFQ=",
"owner": "NixOS",
"repo": "nix",
"rev": "85f1aa6b3df5c5fcc924a74e2a9cc8acea9ba0e1",
"rev": "ed129267dcd7dd2cce48c09b17aefd6cfc488bcd",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nix",
"rev": "ed129267dcd7dd2cce48c09b17aefd6cfc488bcd",
"type": "github"
}
},
@ -292,6 +261,37 @@
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": [
"nix"
],
"gitignore": [
"nix"
],
"nixpkgs": [
"nix",
"nixpkgs"
],
"nixpkgs-stable": [
"nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1724857454,
"narHash": "sha256-Qyl9Q4QMTLZnnBb/8OuQ9LSkzWjBU1T5l5zIzTxkkhk=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "4509ca64f1084e73bc7a721b20c669a8d4c5ebe6",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"purescript-overlay": {
"inputs": {
"nixpkgs": [

View file

@ -3,7 +3,7 @@
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
nix.url = "github:NixOS/nix";
nix.url = "github:NixOS/nix/ed129267dcd7dd2cce48c09b17aefd6cfc488bcd"; # 2.24-pre, before splitting libnixflake
nix.inputs.nixpkgs.follows = "nixpkgs";
nix-cargo-integration.url = "github:yusdacra/nix-cargo-integration";
nix-cargo-integration.inputs.nixpkgs.follows = "nixpkgs";

View file

@ -13,6 +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");
// https://rust-lang.github.io/rust-bindgen/library-usage.html
let bindings = bindgen::Builder::default()

View file

@ -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::err_NIX_ERR_UNKNOWN, cstr.as_ptr());
raw::set_err_msg(context_out, raw::NIX_ERR_UNKNOWN, cstr.as_ptr());
},
}
}

View file

@ -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::err_NIX_OK.try_into().unwrap() {
if err != raw::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::err_NIX_OK.try_into().unwrap(),
raw::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::err_NIX_ERR_KEY } {
if unsafe { raw::err_code(self.inner.as_ptr()) == raw::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::err_NIX_ERR_KEY } {
if unsafe { raw::err_code(ctx.ptr()) == raw::NIX_ERR_KEY } {
ctx.clear();
return Ok(None);
}
@ -143,7 +143,7 @@ mod tests {
unsafe {
raw::set_err_msg(
ctx_ptr,
raw::err_NIX_ERR_UNKNOWN.try_into().unwrap(),
raw::NIX_ERR_UNKNOWN.try_into().unwrap(),
b"dummy error message\0".as_ptr() as *const i8,
);
}