From c701eeb3170af4d5ee64e9abdf8b5df9aa571d00 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Fri, 13 Oct 2023 00:55:00 +0200 Subject: [PATCH] luaPackages.toml: init at 0.3.0 --- pkgs/development/libraries/sol2/default.nix | 36 +++++++++++++ .../lua-modules/generated-packages.nix | 2 +- pkgs/development/lua-modules/toml/default.nix | 52 +++++++++++++++++++ pkgs/development/lua-modules/toml/toml.patch | 43 +++++++++++++++ pkgs/top-level/all-packages.nix | 2 + pkgs/top-level/lua-packages.nix | 2 + 6 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/libraries/sol2/default.nix create mode 100644 pkgs/development/lua-modules/toml/default.nix create mode 100644 pkgs/development/lua-modules/toml/toml.patch diff --git a/pkgs/development/libraries/sol2/default.nix b/pkgs/development/libraries/sol2/default.nix new file mode 100644 index 000000000000..c086d37e6c32 --- /dev/null +++ b/pkgs/development/libraries/sol2/default.nix @@ -0,0 +1,36 @@ +{ fetchFromGitHub +, lib +, stdenv +, cmake +, lua +}: +stdenv.mkDerivation rec{ + pname = "sol2"; + version = "3.3.1"; + src = fetchFromGitHub { + owner = "ThePhD"; + repo = "sol2"; + rev = "v${version}"; + hash = "sha256-7QHZRudxq3hdsfEAYKKJydc4rv6lyN6UIt/2Zmaejx8="; + }; + + nativeBuildInputs = [ cmake lua ]; + + cmakeFlags = [ + "-DSOL2_LUA_VERSION=${lua.version}" + "-DSOL2_BUILD_LUA=FALSE" + ]; + + meta = with lib;{ + description = "Lua API wrapper with advanced features and top notch performance"; + longDescription = '' + sol2 is a C++ library binding to Lua. + It currently supports all Lua versions 5.1+ (LuaJIT 2.0+ and MoonJIT included). + sol2 aims to be easy to use and easy to add to a project. + The library is header-only for easy integration with projects, and a single header can be used for drag-and-drop start up. + ''; + homepage = "https://github.com/ThePhD/sol2"; + license = licenses.mit; + maintainers = with maintainers; [ mrcjkb ]; + }; +} diff --git a/pkgs/development/lua-modules/generated-packages.nix b/pkgs/development/lua-modules/generated-packages.nix index 96f25094c608..8589b4348bd3 100644 --- a/pkgs/development/lua-modules/generated-packages.nix +++ b/pkgs/development/lua-modules/generated-packages.nix @@ -3098,7 +3098,7 @@ buildLuarocksPackage { }; }) {}; -vstruct = callPackage({ fetchgit, lua, buildLuarocksPackage, luaOlder, luarocks-build-rust-mlua}: +vstruct = callPackage({ fetchgit, lua, buildLuarocksPackage, luaOlder }: buildLuarocksPackage { pname = "vstruct"; version = "2.1.1-1"; diff --git a/pkgs/development/lua-modules/toml/default.nix b/pkgs/development/lua-modules/toml/default.nix new file mode 100644 index 000000000000..78cd3eb2cda5 --- /dev/null +++ b/pkgs/development/lua-modules/toml/default.nix @@ -0,0 +1,52 @@ +{ lib +, lua +, luaOlder +, fetchurl +, fetchgit +, buildLuarocksPackage +, tomlplusplus +, magic-enum +, sol2 +}: +buildLuarocksPackage { pname = "toml"; + version = "0.3.0-0"; + knownRockspec = (fetchurl { + url = "mirror://luarocks/toml-0.3.0-0.rockspec"; + sha256 = "0y4qdzsvf4xwnr49xcpbqclrq9d6snv83cbdkrchl0cn4cx6zpxy"; + }).outPath; + src = fetchgit ( removeAttrs (builtins.fromJSON ''{ + "url": "https://github.com/LebJe/toml.lua.git", + "rev": "319e9accf8c5cedf68795354ba81e54c817d1277", + "date": "2023-02-19T23:00:49-05:00", + "path": "/nix/store/p6a98sqp9a4jwsw6ghqcwpn9lxmhvkdg-toml.lua", + "sha256": "05p33bq0ajl41vbsw9bx73shpf0p11n5gb6yy8asvp93zh2m51hq", + "fetchLFS": false, + "fetchSubmodules": true, + "deepClone": false, + "leaveDotGit": false +} + '') ["date" "path"]) ; + + patches = [ ./toml.patch ]; + + disabled = (luaOlder "5.1"); + propagatedBuildInputs = [ + lua + magic-enum + sol2 + ]; + + postPatch = '' + substituteInPlace CMakeLists.txt --replace \ + "TOML_PLUS_PLUS_SRC" \ + "${tomlplusplus.src}" + ''; + + meta = { + homepage = "https://github.com/LebJe/toml.lua"; + description = "TOML v1.0.0 parser and serializer for Lua. Powered by toml++."; + maintainers = with lib.maintainers; [ mrcjkb ]; + license.fullName = "MIT"; + }; +} + diff --git a/pkgs/development/lua-modules/toml/toml.patch b/pkgs/development/lua-modules/toml/toml.patch new file mode 100644 index 000000000000..5f9f57a445db --- /dev/null +++ b/pkgs/development/lua-modules/toml/toml.patch @@ -0,0 +1,43 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index ab3884c..9432df7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -38,26 +38,17 @@ include(FetchContent) + + FetchContent_Declare( + ${TOML++} +- GIT_REPOSITORY "https://github.com/marzer/tomlplusplus.git" +- GIT_SHALLOW ON +- GIT_SUBMODULES "" +- GIT_TAG "v3.3.0" ++ DOWNLOAD_COMMAND true + ) + + FetchContent_Declare( + ${SOL2} +- GIT_REPOSITORY "https://github.com/ThePhD/sol2.git" +- GIT_SHALLOW ON +- GIT_SUBMODULES "" +- GIT_TAG "v3.3.0" ++ DOWNLOAD_COMMAND true + ) + + FetchContent_Declare( + ${MAGIC_ENUM} +- GIT_REPOSITORY "https://github.com/Neargye/magic_enum.git" +- GIT_SHALLOW ON +- GIT_SUBMODULES "" +- GIT_TAG "v0.8.2" ++ DOWNLOAD_COMMAND true + ) + + FetchContent_GetProperties(${TOML++}) +@@ -113,7 +104,7 @@ if(NOT LUA_INCLUDE_DIR OR (WIN32 AND NOT LUA_LIBRARIES)) + find_package(Lua) + endif() + +-include_directories(${LUA_INCLUDE_DIR} src src/include ${${TOML++}_SOURCE_DIR} ${${SOL2}_SOURCE_DIR}/include ${${MAGIC_ENUM}_SOURCE_DIR}/include) ++include_directories(${LUA_INCLUDE_DIR} src src/include TOML_PLUS_PLUS_SRC ${${SOL2}_SOURCE_DIR}/include ${${MAGIC_ENUM}_SOURCE_DIR}/include) + + set(SOURCES + src/toml.cpp diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 23059a6c9b37..58fb771783d8 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -18018,6 +18018,8 @@ with pkgs; bundler-audit = callPackage ../tools/security/bundler-audit { }; + sol2 = callPackage ../development/libraries/sol2 { }; + solargraph = rubyPackages.solargraph; rbenv = callPackage ../development/ruby-modules/rbenv { }; diff --git a/pkgs/top-level/lua-packages.nix b/pkgs/top-level/lua-packages.nix index 1c316c2c1eb0..e177be4b9b93 100644 --- a/pkgs/top-level/lua-packages.nix +++ b/pkgs/top-level/lua-packages.nix @@ -138,6 +138,8 @@ rec { inherit (pkgs.darwin.apple_sdk.frameworks) AppKit; }; + toml = callPackage ../development/lua-modules/toml { }; + toml-edit = callPackage ../development/lua-modules/toml-edit { }; vicious = callPackage ({ fetchFromGitHub }: stdenv.mkDerivation rec {