From 92e201e9387529f96fb72346bc843bc683105e03 Mon Sep 17 00:00:00 2001 From: Lucas Ransan Date: Tue, 3 Aug 2021 14:02:38 +0200 Subject: [PATCH] dictu: init at 0.19.0 --- .../dictu/0001-force-sqlite-to-be-found.patch | 46 ++++++++++ pkgs/development/compilers/dictu/default.nix | 84 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 3 files changed, 132 insertions(+) create mode 100644 pkgs/development/compilers/dictu/0001-force-sqlite-to-be-found.patch create mode 100644 pkgs/development/compilers/dictu/default.nix diff --git a/pkgs/development/compilers/dictu/0001-force-sqlite-to-be-found.patch b/pkgs/development/compilers/dictu/0001-force-sqlite-to-be-found.patch new file mode 100644 index 000000000000..8de4c9f57f6a --- /dev/null +++ b/pkgs/development/compilers/dictu/0001-force-sqlite-to-be-found.patch @@ -0,0 +1,46 @@ +From bb4767f8fc413ca4cb42879a9a226fd26f10e094 Mon Sep 17 00:00:00 2001 +From: Lucas Ransan +Date: Tue, 3 Aug 2021 20:39:11 +0200 +Subject: [PATCH] force sqlite to be found + +--- + src/CMakeLists.txt | 16 +++++----------- + 1 file changed, 5 insertions(+), 11 deletions(-) + +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index a0f3fee..58b4d0b 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -9,7 +9,7 @@ set(INCLUDE_DIR include/) + list(FILTER sources EXCLUDE REGEX "(main|linenoise|utf8).c") + list(FILTER headers EXCLUDE REGEX "(linenoise|utf8).h") + +-find_library(SQLITE_LIB SQLite3) ++find_package(SQLite3 REQUIRED) + set(THREADS) + + if(DISABLE_HTTP) +@@ -20,16 +20,10 @@ else() + list(APPEND libraries curl) + endif() + +-if(NOT SQLITE_LIB) +- set(THREADS_PREFER_PTHREAD_FLAG ON) +- find_package(Threads REQUIRED) +- set(THREADS Threads::Threads) +-else() +- list(FILTER sources EXCLUDE REGEX "sqlite3.c") +- list(FILTER headers EXCLUDE REGEX "sqlite3.h") +- list(APPEND libraries ${SQLITE_LIB}) +- add_compile_definitions(INCLUDE_SQLITE_LIB) +-endif() ++list(FILTER sources EXCLUDE REGEX "sqlite3.c") ++list(FILTER headers EXCLUDE REGEX "sqlite3.h") ++list(APPEND libraries ${SQLite3_LIBRARIES}) ++add_compile_definitions(SQLite3_INCLUDE_DIR) + + if(WIN32) + # ws2_32 is required for winsock2.h to work correctly +-- +2.32.0 + diff --git a/pkgs/development/compilers/dictu/default.nix b/pkgs/development/compilers/dictu/default.nix new file mode 100644 index 000000000000..c67afee81dbe --- /dev/null +++ b/pkgs/development/compilers/dictu/default.nix @@ -0,0 +1,84 @@ +{ stdenv +, lib +, fetchFromGitHub +, cmake +, sqlite +, httpSupport ? true, curl +, cliSupport ? true +, linenoiseSupport ? cliSupport, linenoise +, enableLTO ? stdenv.cc.isGNU +}: + +assert enableLTO -> stdenv.cc.isGNU; + +stdenv.mkDerivation rec { + pname = "dictu"; + version = "0.19.0"; + + src = fetchFromGitHub { + owner = "dictu-lang"; + repo = pname; + rev = "v${version}"; + sha256 = "5Sfmzz4I0dhcbz14LmXx5cHELRFENunLbZmU93uSEJo="; + }; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ + sqlite + ] ++ lib.optional httpSupport curl + ++ lib.optional linenoiseSupport linenoise; + + patches = [ + ./0001-force-sqlite-to-be-found.patch + ]; + + postPatch = lib.optionalString (!enableLTO) '' + sed -i src/CMakeLists.txt \ + -e 's/-flto/${lib.optionalString stdenv.cc.isGNU "-Wno-error=format-truncation"}/' + ''; + + cmakeFlags = [ + "-DBUILD_CLI=${if cliSupport then "ON" else "OFF"}" + "-DDISABLE_HTTP=${if httpSupport then "OFF" else "ON"}" + "-DDISABLE_LINENOISE=${if linenoiseSupport then "OFF" else "ON"}" + ] ++ lib.optionals enableLTO [ # TODO: LTO with LLVM + "-DCMAKE_AR=${stdenv.cc.cc}/bin/gcc-ar" + "-DCMAKE_RANLIB=${stdenv.cc.cc}/bin/gcc-ranlib" + ]; + + doCheck = cliSupport; + + preCheck = '' + cd .. + sed -i tests/runTests.du \ + -e '/http/d' + sed -i tests/path/realpath.du \ + -e 's/usr/build/g' + sed -i tests/path/isDir.du \ + -e 's,/usr/bin,/build/source,' \ + -e '/home/d' + ''; + + checkPhase = '' + runHook preCheck + ./dictu tests/runTests.du + ''; + + installPhase = '' + mkdir -p $out + cp -r /build/source/src/include $out/include + mkdir -p $out/lib + cp /build/source/build/src/libdictu_api* $out/lib + '' + lib.optionalString cliSupport '' + install -Dm755 /build/source/dictu $out/bin/dictu + ''; + + meta = with lib; { + description = "High-level dynamically typed, multi-paradigm, interpreted programming language"; + homepage = "https://dictu-lang.com"; + license = licenses.mit; + maintainers = with maintainers; [ luc65r ]; + platforms = platforms.all; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0ef3ab8e60e7..8ac4f22ca185 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10848,6 +10848,8 @@ in devpi-server = callPackage ../development/tools/devpi-server {}; + dictu = callPackage ../development/compilers/dictu { }; + dotty = callPackage ../development/compilers/scala/dotty.nix { jre = jre8;}; ecl = callPackage ../development/compilers/ecl { };