about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorHung Tran <35638399+Pegasust@users.noreply.github.com>2023-10-03 03:57:07 -0700
committerGitHub <noreply@github.com>2023-10-03 12:57:07 +0200
commit7b6b919f3a707c566b8592106bb7ce070721b137 (patch)
treeab5784284f37b6e8535cb74311732ff2463831a9 /pkgs
parenta7da38888f8f28d47b0b5dc1bc4bd2cdc9bda459 (diff)
neovim: patch liblpeg to work with clang on darwin (#257366)
This is a better-scoped change to patch broken interaction of neovim-lpeg on darwin.

more info at https://github.com/NixOS/nixpkgs/issues/229275

closes #257003
fixes #229275
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/applications/editors/neovim/default.nix27
1 files changed, 25 insertions, 2 deletions
diff --git a/pkgs/applications/editors/neovim/default.nix b/pkgs/applications/editors/neovim/default.nix
index 9bf6fb51bdfff..4b77b2b7c6662 100644
--- a/pkgs/applications/editors/neovim/default.nix
+++ b/pkgs/applications/editors/neovim/default.nix
@@ -7,6 +7,7 @@
 , buildPackages
 , treesitter-parsers ? import ./treesitter-parsers.nix { inherit fetchurl; }
 , CoreServices
+, fixDarwinDylibNames
 , glibcLocales ? null, procps ? null
 
 # now defaults to false because some tests can be flaky (clipboard etc), see
@@ -16,8 +17,29 @@
 }:
 
 let
+  nvim-lpeg-dylib = luapkgs: if stdenv.isDarwin
+    then (luapkgs.lpeg.overrideAttrs (oa: {
+      preConfigure = ''
+        # neovim wants clang .dylib
+        sed -i makefile -e "s/CC = gcc/CC = clang/"
+        sed -i makefile -e "s/-bundle/-dynamiclib/"
+      '';
+      preBuild = ''
+        # there seems to be implicit calls to Makefile from luarocks, we need to
+        # add a stage to build our dylib
+        make macosx
+        mkdir -p $out/lib
+        mv lpeg.so $out/lib/lpeg.dylib
+      '';
+      nativeBuildInputs =
+        oa.nativeBuildInputs
+        ++ (
+          lib.optional stdenv.isDarwin fixDarwinDylibNames
+        );
+    }))
+    else luapkgs.lpeg;
   requiredLuaPkgs = ps: (with ps; [
-    lpeg
+    (nvim-lpeg-dylib ps)
     luabitop
     mpack
   ] ++ lib.optionals doCheck [
@@ -40,10 +62,11 @@ let
             deterministicStringIds = true;
             self = deterministicLuajit;
           };
-        in deterministicLuajit.withPackages(ps: [ ps.mpack ps.lpeg ])
+        in deterministicLuajit.withPackages(ps: [ ps.mpack (nvim-lpeg-dylib ps) ])
       else lua.luaOnBuild;
 
   pyEnv = python3.withPackages(ps: with ps; [ pynvim msgpack ]);
+
 in
   stdenv.mkDerivation rec {
     pname = "neovim-unwrapped";