at 25.11-pre 4.8 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 unzip, 6 zlib, 7 readline, 8 ncurses, 9 updateAutotoolsGnuConfigScriptsHook, 10 11 # for tests 12 python3Packages, 13 sqldiff, 14 sqlite-analyzer, 15 sqlite-rsync, 16 tinysparql, 17 18 # uses readline & ncurses for a better interactive experience if set to true 19 interactive ? false, 20 21 gitUpdater, 22}: 23 24let 25 archiveVersion = import ./archive-version.nix lib; 26in 27 28stdenv.mkDerivation rec { 29 pname = "sqlite${lib.optionalString interactive "-interactive"}"; 30 version = "3.48.0"; 31 32 # nixpkgs-update: no auto update 33 # NB! Make sure to update ./tools.nix src (in the same directory). 34 src = fetchurl { 35 url = "https://sqlite.org/2025/sqlite-autoconf-${archiveVersion version}.tar.gz"; 36 hash = "sha256-rJkvf8o5id5+0f6ZwWNj+Eh5TIwyoVja/U65J6LgL9U="; 37 }; 38 docsrc = fetchurl { 39 url = "https://sqlite.org/2025/sqlite-doc-${archiveVersion version}.zip"; 40 hash = "sha256-PcE3/NfGrLMmr2CmG5hE3RXTdzywXnqc4nbEH3E9dlo="; 41 }; 42 43 patches = [ 44 # https://sqlite.org/forum/forumpost/3380558ea82c8a3e 45 # Can be removed with the next release. 46 # Test: pkgsStatic.gnupg 47 ./Libs.private.patch 48 49 # https://sqlite.org/forum/forumpost/00f3aab3d3be9690 50 # https://sqlite.org/src/info/d7c07581 51 # TODO: Remove in 3.49.0 52 ./3.48.0-fk-conflict-handling.patch 53 ]; 54 55 outputs = [ 56 "bin" 57 "dev" 58 "man" 59 "doc" 60 "out" 61 ]; 62 separateDebugInfo = stdenv.hostPlatform.isLinux; 63 64 nativeBuildInputs = [ 65 updateAutotoolsGnuConfigScriptsHook 66 unzip 67 ]; 68 buildInputs = 69 [ zlib ] 70 ++ lib.optionals interactive [ 71 readline 72 ncurses 73 ]; 74 75 # required for aarch64 but applied for all arches for simplicity 76 preConfigure = '' 77 patchShebangs configure 78 ''; 79 80 configureFlags = [ "--enable-threadsafe" ] ++ lib.optional interactive "--enable-readline"; 81 82 env.NIX_CFLAGS_COMPILE = toString ([ 83 "-DSQLITE_ENABLE_COLUMN_METADATA" 84 "-DSQLITE_ENABLE_DBSTAT_VTAB" 85 "-DSQLITE_ENABLE_JSON1" 86 "-DSQLITE_ENABLE_FTS3" 87 "-DSQLITE_ENABLE_FTS3_PARENTHESIS" 88 "-DSQLITE_ENABLE_FTS3_TOKENIZER" 89 "-DSQLITE_ENABLE_FTS4" 90 "-DSQLITE_ENABLE_FTS5" 91 "-DSQLITE_ENABLE_PREUPDATE_HOOK" 92 "-DSQLITE_ENABLE_RTREE" 93 "-DSQLITE_ENABLE_SESSION" 94 "-DSQLITE_ENABLE_STMT_SCANSTATUS" 95 "-DSQLITE_ENABLE_UNLOCK_NOTIFY" 96 "-DSQLITE_SOUNDEX" 97 "-DSQLITE_SECURE_DELETE" 98 "-DSQLITE_MAX_VARIABLE_NUMBER=250000" 99 "-DSQLITE_MAX_EXPR_DEPTH=10000" 100 ]); 101 102 # Test for features which may not be available at compile time 103 preBuild = '' 104 # Use pread(), pread64(), pwrite(), pwrite64() functions for better performance if they are available. 105 if cc -Werror=implicit-function-declaration -x c - -o "$TMPDIR/pread_pwrite_test" <<< \ 106 ''$'#include <unistd.h>\nint main()\n{\n pread(0, NULL, 0, 0);\n pwrite(0, NULL, 0, 0);\n return 0;\n}'; then 107 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -DUSE_PREAD" 108 fi 109 if cc -Werror=implicit-function-declaration -x c - -o "$TMPDIR/pread64_pwrite64_test" <<< \ 110 ''$'#include <unistd.h>\nint main()\n{\n pread64(0, NULL, 0, 0);\n pwrite64(0, NULL, 0, 0);\n return 0;\n}'; then 111 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -DUSE_PREAD64" 112 elif cc -D_LARGEFILE64_SOURCE -Werror=implicit-function-declaration -x c - -o "$TMPDIR/pread64_pwrite64_test" <<< \ 113 ''$'#include <unistd.h>\nint main()\n{\n pread64(0, NULL, 0, 0);\n pwrite64(0, NULL, 0, 0);\n return 0;\n}'; then 114 export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -DUSE_PREAD64 -D_LARGEFILE64_SOURCE" 115 fi 116 117 # Necessary for FTS5 on Linux 118 export NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -lm" 119 120 echo "" 121 echo "NIX_CFLAGS_COMPILE = $NIX_CFLAGS_COMPILE" 122 echo "" 123 ''; 124 125 postInstall = '' 126 mkdir -p $doc/share/doc 127 unzip $docsrc 128 mv sqlite-doc-${archiveVersion version} $doc/share/doc/sqlite 129 ''; 130 131 doCheck = false; # fails to link against tcl 132 133 passthru = { 134 tests = { 135 inherit (python3Packages) sqlalchemy; 136 inherit 137 sqldiff 138 sqlite-analyzer 139 sqlite-rsync 140 tinysparql 141 ; 142 }; 143 144 updateScript = gitUpdater { 145 # No nicer place to look for patest version. 146 url = "https://github.com/sqlite/sqlite.git"; 147 # Expect tags like "version-3.43.0". 148 rev-prefix = "version-"; 149 }; 150 }; 151 152 meta = with lib; { 153 changelog = "https://www.sqlite.org/releaselog/${lib.replaceStrings [ "." ] [ "_" ] version}.html"; 154 description = "Self-contained, serverless, zero-configuration, transactional SQL database engine"; 155 downloadPage = "https://sqlite.org/download.html"; 156 homepage = "https://www.sqlite.org/"; 157 license = licenses.publicDomain; 158 mainProgram = "sqlite3"; 159 maintainers = with maintainers; [ np ]; 160 platforms = platforms.unix ++ platforms.windows; 161 pkgConfigModules = [ "sqlite3" ]; 162 }; 163}