Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at gcc-offload 122 lines 4.4 kB view raw
1{ lib, stdenv, fetchurl, unzip, zlib, readline, ncurses 2, updateAutotoolsGnuConfigScriptsHook 3 4# for tests 5, python3Packages, sqldiff, sqlite-analyzer, tinysparql 6 7# uses readline & ncurses for a better interactive experience if set to true 8, interactive ? false 9 10, gitUpdater 11}: 12 13let 14 archiveVersion = import ./archive-version.nix lib; 15in 16 17stdenv.mkDerivation rec { 18 pname = "sqlite${lib.optionalString interactive "-interactive"}"; 19 version = "3.46.1"; 20 21 # nixpkgs-update: no auto update 22 # NB! Make sure to update ./tools.nix src (in the same directory). 23 src = fetchurl { 24 url = "https://sqlite.org/2024/sqlite-autoconf-${archiveVersion version}.tar.gz"; 25 hash = "sha256-Z9P+bSaObq3crjcn/OWPzI6cU4ab3Qegxh443fKWUHE="; 26 }; 27 docsrc = fetchurl { 28 url = "https://sqlite.org/2024/sqlite-doc-${archiveVersion version}.zip"; 29 hash = "sha256-6WkTH5PKefvGTVdyShA1c1iBVVpSYA2+acaeq3LJ/NE="; 30 }; 31 32 outputs = [ "bin" "dev" "man" "doc" "out" ]; 33 separateDebugInfo = stdenv.hostPlatform.isLinux; 34 35 nativeBuildInputs = [ updateAutotoolsGnuConfigScriptsHook unzip ]; 36 buildInputs = [ zlib ] ++ lib.optionals interactive [ readline ncurses ]; 37 38 # required for aarch64 but applied for all arches for simplicity 39 preConfigure = '' 40 patchShebangs configure 41 ''; 42 43 configureFlags = [ "--enable-threadsafe" ] ++ lib.optional interactive "--enable-readline"; 44 45 env.NIX_CFLAGS_COMPILE = toString ([ 46 "-DSQLITE_ENABLE_COLUMN_METADATA" 47 "-DSQLITE_ENABLE_DBSTAT_VTAB" 48 "-DSQLITE_ENABLE_JSON1" 49 "-DSQLITE_ENABLE_FTS3" 50 "-DSQLITE_ENABLE_FTS3_PARENTHESIS" 51 "-DSQLITE_ENABLE_FTS3_TOKENIZER" 52 "-DSQLITE_ENABLE_FTS4" 53 "-DSQLITE_ENABLE_FTS5" 54 "-DSQLITE_ENABLE_RTREE" 55 "-DSQLITE_ENABLE_STMT_SCANSTATUS" 56 "-DSQLITE_ENABLE_UNLOCK_NOTIFY" 57 "-DSQLITE_SOUNDEX" 58 "-DSQLITE_SECURE_DELETE" 59 "-DSQLITE_MAX_VARIABLE_NUMBER=250000" 60 "-DSQLITE_MAX_EXPR_DEPTH=10000" 61 ]); 62 63 # Test for features which may not be available at compile time 64 preBuild = '' 65 # Use pread(), pread64(), pwrite(), pwrite64() functions for better performance if they are available. 66 if cc -Werror=implicit-function-declaration -x c - -o "$TMPDIR/pread_pwrite_test" <<< \ 67 ''$'#include <unistd.h>\nint main()\n{\n pread(0, NULL, 0, 0);\n pwrite(0, NULL, 0, 0);\n return 0;\n}'; then 68 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -DUSE_PREAD" 69 fi 70 if cc -Werror=implicit-function-declaration -x c - -o "$TMPDIR/pread64_pwrite64_test" <<< \ 71 ''$'#include <unistd.h>\nint main()\n{\n pread64(0, NULL, 0, 0);\n pwrite64(0, NULL, 0, 0);\n return 0;\n}'; then 72 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -DUSE_PREAD64" 73 elif cc -D_LARGEFILE64_SOURCE -Werror=implicit-function-declaration -x c - -o "$TMPDIR/pread64_pwrite64_test" <<< \ 74 ''$'#include <unistd.h>\nint main()\n{\n pread64(0, NULL, 0, 0);\n pwrite64(0, NULL, 0, 0);\n return 0;\n}'; then 75 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -DUSE_PREAD64 -D_LARGEFILE64_SOURCE" 76 fi 77 78 # Necessary for FTS5 on Linux 79 export NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -lm" 80 81 echo "" 82 echo "NIX_CFLAGS_COMPILE = $NIX_CFLAGS_COMPILE" 83 echo "" 84 ''; 85 86 postInstall = '' 87 # Do not contaminate dependent libtool-based projects with sqlite dependencies. 88 sed -i $out/lib/libsqlite3.la -e "s/dependency_libs=.*/dependency_libs='''/" 89 90 mkdir -p $doc/share/doc 91 unzip $docsrc 92 mv sqlite-doc-${archiveVersion version} $doc/share/doc/sqlite 93 ''; 94 95 doCheck = false; # fails to link against tcl 96 97 passthru = { 98 tests = { 99 inherit (python3Packages) sqlalchemy; 100 inherit sqldiff sqlite-analyzer tinysparql; 101 }; 102 103 updateScript = gitUpdater { 104 # No nicer place to look for patest version. 105 url = "https://github.com/sqlite/sqlite.git"; 106 # Expect tags like "version-3.43.0". 107 rev-prefix = "version-"; 108 }; 109 }; 110 111 meta = with lib; { 112 changelog = "https://www.sqlite.org/releaselog/${lib.replaceStrings [ "." ] [ "_" ] version}.html"; 113 description = "Self-contained, serverless, zero-configuration, transactional SQL database engine"; 114 downloadPage = "https://sqlite.org/download.html"; 115 homepage = "https://www.sqlite.org/"; 116 license = licenses.publicDomain; 117 mainProgram = "sqlite3"; 118 maintainers = with maintainers; [ np ]; 119 platforms = platforms.unix ++ platforms.windows; 120 pkgConfigModules = [ "sqlite3" ]; 121 }; 122}