Unverified Commit 1b91c4ae authored by Austin Horstman's avatar Austin Horstman
Browse files

lua-modules/overrides: format

parent cd90ea85
Loading
Loading
Loading
Loading
+330 −195
Original line number Diff line number Diff line
# do not add pkgs, it messes up splicing
{ stdenv
, cargo
, cmake
{
  stdenv,
  cargo,
  cmake,

  # plenary utilities
, which
, findutils
, clang
, coreutils
, curl
, cyrus_sasl
, dbus
, expat
, fetchFromGitHub
, fetchpatch
, fetchurl
, fixDarwinDylibNames
, glib
, glibc
, gmp
, gnulib
, gnum4
, gobject-introspection
, imagemagick
, installShellFiles
, lib
, libevent
, libiconv
, libmpack
, libmysqlclient
, libpsl
, libpq
, libuuid
, libuv
, libxcrypt
, libyaml
, luajitPackages
, lua-language-server
, mariadb
, magic-enum
, mpfr
, neovim-unwrapped
, openldap
, openssl
, pcre
, pkg-config
, readline
, rustPlatform
, sol2
, sqlite
, tomlplusplus
, tree-sitter
, unbound
, vimPlugins
, vimUtils
, yajl
, zip
, unzip
, zlib
, zziplib
  which,
  findutils,
  clang,
  coreutils,
  curl,
  cyrus_sasl,
  dbus,
  expat,
  fetchFromGitHub,
  fetchpatch,
  fetchurl,
  fixDarwinDylibNames,
  glib,
  glibc,
  gmp,
  gnulib,
  gnum4,
  gobject-introspection,
  imagemagick,
  installShellFiles,
  lib,
  libevent,
  libiconv,
  libmpack,
  libmysqlclient,
  libpsl,
  libpq,
  libuuid,
  libuv,
  libxcrypt,
  libyaml,
  luajitPackages,
  lua-language-server,
  mariadb,
  magic-enum,
  mpfr,
  neovim-unwrapped,
  openldap,
  openssl,
  pcre,
  pkg-config,
  readline,
  rustPlatform,
  sol2,
  sqlite,
  tomlplusplus,
  tree-sitter,
  unbound,
  vimPlugins,
  vimUtils,
  yajl,
  zip,
  unzip,
  zlib,
  zziplib,
}:

final: prev:
let
  inherit (prev) luaOlder luaAtLeast lua isLuaJIT isLua51;
  inherit (prev)
    luaOlder
    luaAtLeast
    lua
    isLuaJIT
    isLua51
    ;
in
{
  argparse = prev.argparse.overrideAttrs (oa: {
@@ -108,7 +115,8 @@ in

  cqueues = prev.cqueues.overrideAttrs (oa: rec {
    # Parse out a version number without the Lua version inserted
    version = let
    version =
      let
        version' = prev.cqueues.version;
        rel = lib.splitVersion version';
        date = lib.head rel;
@@ -123,13 +131,22 @@ in
    ];

    externalDeps = [
      { name = "CRYPTO"; dep = openssl; }
      { name = "OPENSSL"; dep = openssl; }
      {
        name = "CRYPTO";
        dep = openssl;
      }
      {
        name = "OPENSSL";
        dep = openssl;
      }
    ];

    # Upstream rockspec is pointlessly broken into separate rockspecs, per Lua
    # version, which doesn't work well for us, so modify it
    postConfigure = let inherit (prev.cqueues) pname; in
    postConfigure =
      let
        inherit (prev.cqueues) pname;
      in
      ''
        # 'all' target auto-detects correct Lua version, which is fine for us as
        # we only have the right one available :)
@@ -161,7 +178,8 @@ in
        sha256 = "1vmx039n3nqfx50faqhs3wgiw28ws416rhw6vh6srmh9i826dac7";
      })
    ];
    /* TODO: separate docs derivation? (pandoc is heavy)
    /*
      TODO: separate docs derivation? (pandoc is heavy)
      nativeBuildInputs = [ pandoc ];
      makeFlags = [ "-C doc" "lua-http.html" "lua-http.3" ];
    */
@@ -242,10 +260,13 @@ in
    propagatedBuildInputs = oa.propagatedBuildInputs ++ [ lua-language-server ];
  });

  lmathx = prev.luaLib.overrideLuarocks prev.lmathx (drv:
    if luaAtLeast "5.1" && luaOlder "5.2" then {
  lmathx = prev.luaLib.overrideLuarocks prev.lmathx (
    drv:
    if luaAtLeast "5.1" && luaOlder "5.2" then
      {
        version = "20120430.51-1";
      knownRockspec = (fetchurl {
        knownRockspec =
          (fetchurl {
            url = "mirror://luarocks/lmathx-20120430.51-1.rockspec";
            sha256 = "148vbv2g3z5si2db7rqg5bdily7m4sjyh9w6r3jnx3csvfaxyhp0";
          }).outPath;
@@ -253,10 +274,12 @@ in
          url = "https://web.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/lmathx.tar.gz";
          sha256 = "0sa553d0zlxhvpsmr4r7d841f16yq4wr3fg7i07ibxkz6yzxax51";
        };
    } else
      if luaAtLeast "5.2" && luaOlder "5.3" then {
      }
    else if luaAtLeast "5.2" && luaOlder "5.3" then
      {
        version = "20120430.52-1";
        knownRockspec = (fetchurl {
        knownRockspec =
          (fetchurl {
            url = "mirror://luarocks/lmathx-20120430.52-1.rockspec";
            sha256 = "14rd625sipakm72wg6xqsbbglaxyjba9nsajsfyvhg0sz8qjgdya";
          }).outPath;
@@ -264,7 +287,8 @@ in
          url = "http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.2/lmathx.tar.gz";
          sha256 = "19dwa4z266l2njgi6fbq9rak4rmx2fsx1s0p9sl166ar3mnrdwz5";
        };
      } else
      }
    else
      {
        disabled = luaOlder "5.1" || luaAtLeast "5.5";
        # works fine with 5.4 as well
@@ -272,12 +296,19 @@ in
          substituteInPlace ''${rockspecFilename} \
            --replace 'lua ~> 5.3' 'lua >= 5.3, < 5.5'
        '';
        });
      }
  );

  lmpfrlib = prev.lmpfrlib.overrideAttrs (oa: {
    externalDeps = [
      { name = "GMP"; dep = gmp; }
      { name = "MPFR"; dep = mpfr; }
      {
        name = "GMP";
        dep = gmp;
      }
      {
        name = "MPFR";
        dep = mpfr;
      }
    ];
    unpackPhase = ''
      cp $src $(stripHash $src)
@@ -292,7 +323,10 @@ in

  lrexlib-pcre = prev.lrexlib-pcre.overrideAttrs (oa: {
    externalDeps = [
      { name = "PCRE"; dep = pcre; }
      {
        name = "PCRE";
        dep = pcre;
      }
    ];
  });

@@ -342,7 +376,9 @@ in
    buildInputs = oa.buildInputs ++ [
      zlib.dev
    ];
    meta = oa.meta // { broken = luaOlder "5.1" || luaAtLeast "5.4"; };
    meta = oa.meta // {
      broken = luaOlder "5.1" || luaAtLeast "5.4";
    };
  });

  luadbi-mysql = prev.luadbi-mysql.overrideAttrs (oa: {
@@ -367,7 +403,10 @@ in

  luadbi-sqlite3 = prev.luadbi-sqlite3.overrideAttrs (oa: {
    externalDeps = [
      { name = "SQLITE"; dep = sqlite; }
      {
        name = "SQLITE";
        dep = sqlite;
      }
    ];
  });

@@ -376,14 +415,20 @@ in
      final.luasocket
    ];
    externalDeps = [
      { name = "EVENT"; dep = libevent; }
      {
        name = "EVENT";
        dep = libevent;
      }
    ];
    meta.broken = luaOlder "5.1" || luaAtLeast "5.4";
  });

  luaexpat = prev.luaexpat.overrideAttrs (_: {
    externalDeps = [
      { name = "EXPAT"; dep = expat; }
      {
        name = "EXPAT";
        dep = expat;
      }
    ];
  });

@@ -403,27 +448,45 @@ in

  lualdap = prev.lualdap.overrideAttrs (_: {
    externalDeps = [
      { name = "LDAP"; dep = openldap; }
      {
        name = "LDAP";
        dep = openldap;
      }
    ];
  });

  luaossl = prev.luaossl.overrideAttrs (_: {
    externalDeps = [
      { name = "CRYPTO"; dep = openssl; }
      { name = "OPENSSL"; dep = openssl; }
      {
        name = "CRYPTO";
        dep = openssl;
      }
      {
        name = "OPENSSL";
        dep = openssl;
      }
    ];
  });

  luaposix = prev.luaposix.overrideAttrs (_: {
    externalDeps = [
      { name = "CRYPT"; dep = libxcrypt; }
      {
        name = "CRYPT";
        dep = libxcrypt;
      }
    ];
  });

  luaprompt = prev.luaprompt.overrideAttrs (oa: {
    externalDeps = [
      { name = "READLINE"; dep = readline; }
      { name = "HISTORY"; dep = readline; }
      {
        name = "READLINE";
        dep = readline;
      }
      {
        name = "HISTORY";
        dep = readline;
      }
    ];

    nativeBuildInputs = oa.nativeBuildInputs ++ [ installShellFiles ];
@@ -436,11 +499,19 @@ in
  # As a nix user, use this derivation instead of "luarocks_bootstrap"
  luarocks = prev.luarocks.overrideAttrs (oa: {

    nativeBuildInputs = oa.nativeBuildInputs ++ [ installShellFiles lua unzip ];
    nativeBuildInputs = oa.nativeBuildInputs ++ [
      installShellFiles
      lua
      unzip
    ];
    # cmake is just to compile packages with "cmake" buildType, not luarocks itself
    dontUseCmakeConfigure = true;

    propagatedBuildInputs = [ zip unzip cmake ];
    propagatedBuildInputs = [
      zip
      unzip
      cmake
    ];

    postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
      installShellCompletion --cmd luarocks \
@@ -462,19 +533,28 @@ in

  luasec = prev.luasec.overrideAttrs (oa: {
    externalDeps = [
      { name = "OPENSSL"; dep = openssl; }
      {
        name = "OPENSSL";
        dep = openssl;
      }
    ];
  });

  luasql-sqlite3 = prev.luasql-sqlite3.overrideAttrs (oa: {
    externalDeps = [
      { name = "SQLITE"; dep = sqlite; }
      {
        name = "SQLITE";
        dep = sqlite;
      }
    ];
  });

  luasystem = prev.luasystem.overrideAttrs (oa: lib.optionalAttrs stdenv.hostPlatform.isLinux {
  luasystem = prev.luasystem.overrideAttrs (
    oa:
    lib.optionalAttrs stdenv.hostPlatform.isLinux {
      buildInputs = [ glibc.out ];
  });
    }
  );

  luazip = prev.luazip.overrideAttrs (oa: {
    buildInputs = oa.buildInputs ++ [
@@ -495,7 +575,10 @@ in

  luaunbound = prev.luaunbound.overrideAttrs (oa: {
    externalDeps = [
      { name = "libunbound"; dep = unbound; }
      {
        name = "libunbound";
        dep = unbound;
      }
    ];
  });

@@ -510,7 +593,10 @@ in
      hash = "sha256-7mFn4dLgaxfAxtPFCc3VzcBx2HuywcZTYqCGTbaGS0k=";
    };

    propagatedBuildInputs = oa.propagatedBuildInputs ++ [ cargo rustPlatform.cargoSetupHook ];
    propagatedBuildInputs = oa.propagatedBuildInputs ++ [
      cargo
      rustPlatform.cargoSetupHook
    ];

    # ld: symbol(s) not found for architecture arm64
    # clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
@@ -527,7 +613,10 @@ in

  luuid = prev.luuid.overrideAttrs (oa: {
    externalDeps = [
      { name = "LIBUUID"; dep = libuuid; }
      {
        name = "LIBUUID";
        dep = libuuid;
      }
    ];
    # Trivial patch to make it work in both 5.1 and 5.2.  Basically just the
    # tiny diff between the two upstream versions placed behind an #if.
@@ -549,7 +638,10 @@ in

  lz-n = prev.lz-n.overrideAttrs (oa: {
    doCheck = lua.luaversion == "5.1";
    nativeCheckInputs = [ final.nlua final.busted ];
    nativeCheckInputs = [
      final.nlua
      final.busted
    ];
    checkPhase = ''
      runHook preCheck
      export HOME=$(mktemp -d)
@@ -560,7 +652,10 @@ in

  lze = prev.lze.overrideAttrs (oa: {
    doCheck = lua.luaversion == "5.1";
    nativeCheckInputs = [ final.nlua final.busted ];
    nativeCheckInputs = [
      final.nlua
      final.busted
    ];
    checkPhase = ''
      runHook preCheck
      export HOME=$(mktemp -d)
@@ -572,7 +667,9 @@ in
  neotest = prev.neotest.overrideAttrs (oa: {
    doCheck = stdenv.hostPlatform.isLinux;
    nativeCheckInputs = oa.nativeCheckInputs ++ [
      final.nlua final.busted neovim-unwrapped
      final.nlua
      final.busted
      neovim-unwrapped
    ];

    checkPhase = ''
@@ -589,7 +686,10 @@ in

  haskell-tools-nvim = prev.haskell-tools-nvim.overrideAttrs (oa: {
    doCheck = lua.luaversion == "5.1";
    nativeCheckInputs = [ final.nlua final.busted ];
    nativeCheckInputs = [
      final.nlua
      final.busted
    ];
    checkPhase = ''
      runHook preCheck
      export HOME=$(mktemp -d)
@@ -608,7 +708,10 @@ in

  nvim-nio = prev.nvim-nio.overrideAttrs (oa: {
    doCheck = lua.luaversion == "5.1";
    nativeCheckInputs = [ final.nlua final.busted ];
    nativeCheckInputs = [
      final.nlua
      final.busted
    ];

    # upstream uses PlenaryBusted which is a pain to setup
    checkPhase = ''
@@ -665,10 +768,15 @@ in
      rm -rf deps/lua deps/libuv
    '';

    buildInputs = [ libuv final.lua ];
    buildInputs = [
      libuv
      final.lua
    ];

    nativeBuildInputs = [ pkg-config cmake ]
      ++ lib.optionals stdenv.hostPlatform.isDarwin [ fixDarwinDylibNames ];
    nativeBuildInputs = [
      pkg-config
      cmake
    ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ fixDarwinDylibNames ];
  };

  luv = prev.luv.overrideAttrs (oa: {
@@ -678,7 +786,9 @@ in

    # Use system libuv instead of building local and statically linking
    luarocksConfig = lib.recursiveUpdate oa.luarocksConfig {
      variables = { WITH_SHARED_LIBUV = "ON"; };
      variables = {
        WITH_SHARED_LIBUV = "ON";
      };
    };

    # we unset the LUA_PATH since the hook erases the interpreter defaults (To fix)
@@ -749,11 +859,20 @@ in
  });

  # upstream broken, can't be generated, so moved out from the generated set
  readline = final.callPackage({ buildLuarocksPackage, fetchurl, luaAtLeast, luaOlder, lua, luaposix }:
  readline = final.callPackage (
    {
      buildLuarocksPackage,
      fetchurl,
      luaAtLeast,
      luaOlder,
      lua,
      luaposix,
    }:
    buildLuarocksPackage ({
      pname = "readline";
      version = "3.2-0";
    knownRockspec = (fetchurl {
      knownRockspec =
        (fetchurl {
          url = "mirror://luarocks/readline-3.2-0.rockspec";
          sha256 = "1r0sgisxm4xd1r6i053iibxh30j7j3rcj4wwkd8rzkj8nln20z24";
        }).outPath;
@@ -784,11 +903,15 @@ in
        license.fullName = "MIT/X11";
        broken = (luaOlder "5.1") || (luaAtLeast "5.5");
      };
  })) {};
    })
  ) { };

  rtp-nvim = prev.rtp-nvim.overrideAttrs (oa: {
    doCheck = lua.luaversion == "5.1";
    nativeCheckInputs = [ final.nlua final.busted ];
    nativeCheckInputs = [
      final.nlua
      final.busted
    ];
    checkPhase = ''
      runHook preCheck
      export HOME=$(mktemp -d)
@@ -799,7 +922,10 @@ in

  rustaceanvim = prev.rustaceanvim.overrideAttrs (oa: {
    doCheck = lua.luaversion == "5.1";
    nativeCheckInputs = [ final.nlua final.busted ];
    nativeCheckInputs = [
      final.nlua
      final.busted
    ];
    checkPhase = ''
      runHook preCheck
      export HOME=$(mktemp -d)
@@ -810,7 +936,10 @@ in

  sqlite = prev.sqlite.overrideAttrs (drv: {
    doCheck = stdenv.hostPlatform.isLinux;
    nativeCheckInputs = [ final.plenary-nvim neovim-unwrapped ];
    nativeCheckInputs = [
      final.plenary-nvim
      neovim-unwrapped
    ];

    # the plugin loads the library from either the LIBSQLITE env
    # or the vim.g.sqlite_clib_path variable.
@@ -849,7 +978,10 @@ in
      src = oa.src;
      hash = "sha256-sO2q4cmkJc6T4iyJUWpBfr2ISycS1cXAIO0ibMfzyIE=";
    };
    nativeBuildInputs = oa.nativeBuildInputs ++ [ cargo rustPlatform.cargoSetupHook ];
    nativeBuildInputs = oa.nativeBuildInputs ++ [
      cargo
      rustPlatform.cargoSetupHook
    ];
  });

  tl = prev.tl.overrideAttrs ({
@@ -865,8 +997,9 @@ in
      hash = "sha256-ow0zefFFrU91Q2PJww2jtd6nqUjwXUtfQzjkzl/AXuo=";
    };

    NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin
      (if lua.pkgs.isLuaJIT then "-lluajit-${lua.luaversion}" else "-llua");
    NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin (
      if lua.pkgs.isLuaJIT then "-lluajit-${lua.luaversion}" else "-llua"
    );

    nativeBuildInputs = oa.nativeBuildInputs ++ [
      cargo
@@ -895,11 +1028,14 @@ in
  });

  tree-sitter-norg = prev.tree-sitter-norg.overrideAttrs (oa: {
    propagatedBuildInputs = let
    propagatedBuildInputs =
      let
        # HACK: luarocks-nix puts rockspec build dependencies in the nativeBuildInputs,
        # but that doesn't seem to work
        lua = lib.head oa.propagatedBuildInputs;
    in oa.propagatedBuildInputs ++ [
      in
      oa.propagatedBuildInputs
      ++ [
        lua.pkgs.luarocks-build-treesitter-parser-cpp
      ];
  });
@@ -933,7 +1069,6 @@ in
    '';
  });


  # aliases
  cjson = prev.lua-cjson;
}