From 69d4ccc42235a74f54f2146d489a4a350144baa5 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 2 Sep 2024 14:25:31 +0200 Subject: [PATCH] fix: Temporarily revert Nix to recover getFlake https://github.com/NixOS/nix/issues/11399 (cherry picked from commit 0f2ae7d080dda34938517f781b4eb436522e9d65) --- flake.lock | 80 ++++++++++++++++++------------------ flake.nix | 2 +- rust/nix-c-raw/build.rs | 1 + rust/nix-expr/src/primop.rs | 2 +- rust/nix-util/src/context.rs | 10 ++--- 5 files changed, 48 insertions(+), 47 deletions(-) diff --git a/flake.lock b/flake.lock index bb36bb7..f031e6b 100644 --- a/flake.lock +++ b/flake.lock @@ -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": [ diff --git a/flake.nix b/flake.nix index c67d7f1..a952e05 100644 --- a/flake.nix +++ b/flake.nix @@ -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"; diff --git a/rust/nix-c-raw/build.rs b/rust/nix-c-raw/build.rs index c544fe8..541ea9a 100644 --- a/rust/nix-c-raw/build.rs +++ b/rust/nix-c-raw/build.rs @@ -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() diff --git a/rust/nix-expr/src/primop.rs b/rust/nix-expr/src/primop.rs index 9234954..9641abe 100644 --- a/rust/nix-expr/src/primop.rs +++ b/rust/nix-expr/src/primop.rs @@ -114,7 +114,7 @@ unsafe extern "C" fn function_adapter( CString::new("") .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()); }, } } diff --git a/rust/nix-util/src/context.rs b/rust/nix-util/src/context.rs index d4dbe94..dd0aecc 100644 --- a/rust/nix-util/src/context.rs +++ b/rust/nix-util/src/context.rs @@ -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> { 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, ); }