From 027c5d4603059eb17afe76e337429d70ff3b765f Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Mon, 15 Mar 2021 15:20:57 -0700 Subject: [PATCH] build: patch lmdb to use F_FULLFSYNC on darwin --- nix/overlays/native.nix | 11 +++++++++++ nix/pkgs/lmdb/darwin-fsync.patch | 13 +++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 nix/pkgs/lmdb/darwin-fsync.patch diff --git a/nix/overlays/native.nix b/nix/overlays/native.nix index 2ab55e3751..20d6b1ff9b 100644 --- a/nix/overlays/native.nix +++ b/nix/overlays/native.nix @@ -25,4 +25,15 @@ in { ldapSupport = false; brotliSupport = false; }; + + lmdb = prev.lmdb.overrideAttrs (attrs: { + patches = + if builtins.currentSystem != "x86_64-darwin" + then + attrs.patches + else + optionalList attrs.patches ++ [ + ../pkgs/lmdb/darwin-fsync.patch + ]; + }); } diff --git a/nix/pkgs/lmdb/darwin-fsync.patch b/nix/pkgs/lmdb/darwin-fsync.patch new file mode 100644 index 0000000000..961b8a1ffd --- /dev/null +++ b/nix/pkgs/lmdb/darwin-fsync.patch @@ -0,0 +1,13 @@ +diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c +index fe65e30..0070215 100644 +--- a/libraries/liblmdb/mdb.c ++++ b/libraries/liblmdb/mdb.c +@@ -2526,7 +2526,7 @@ mdb_env_sync(MDB_env *env, int force) + rc = ErrCode(); + } else + #endif +- if (MDB_FDATASYNC(env->me_fd)) ++ if (fcntl(env->me_fd, F_FULLFSYNC, 0)) + rc = ErrCode(); + } + }