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