at master 4.1 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 unzip, 6 zlib, 7 readline, 8 ncurses, 9 10 # for tests 11 python3Packages, 12 sqldiff, 13 sqlite-analyzer, 14 sqlite-rsync, 15 tinysparql, 16 17 # uses readline & ncurses for a better interactive experience if set to true 18 interactive ? false, 19 20 gitUpdater, 21 buildPackages, 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.50.2"; 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-hKYW/9MXOORZC2W6uzqeHvk3DzY4422yIO4Oc/itIVY="; 37 }; 38 docsrc = fetchurl { 39 url = "https://sqlite.org/2025/sqlite-doc-${archiveVersion version}.zip"; 40 hash = "sha256-n4uitTo6oskWbUagLZEbhdO4sLhAxJHTIdX8YhUONBk="; 41 }; 42 43 outputs = [ 44 "bin" 45 "dev" 46 "man" 47 "doc" 48 "out" 49 ]; 50 separateDebugInfo = stdenv.hostPlatform.isLinux; 51 52 depsBuildBuild = [ 53 buildPackages.stdenv.cc 54 ]; 55 56 nativeBuildInputs = [ 57 unzip 58 ]; 59 buildInputs = [ 60 zlib 61 ] 62 ++ lib.optionals interactive [ 63 readline 64 ncurses 65 ]; 66 67 # required for aarch64 but applied for all arches for simplicity 68 preConfigure = '' 69 patchShebangs configure 70 ''; 71 72 # sqlite relies on autosetup now; so many of the 73 # previously-understood flags are gone. They should instead be set 74 # on a per-output basis. 75 setOutputFlags = false; 76 77 configureFlags = [ 78 "--bindir=${placeholder "bin"}/bin" 79 "--includedir=${placeholder "dev"}/include" 80 "--libdir=${placeholder "out"}/lib" 81 ] 82 ++ lib.optional (!interactive) "--disable-readline" 83 # autosetup only looks up readline.h in predefined set of directories. 84 ++ lib.optional interactive "--with-readline-header=${lib.getDev readline}/include/readline/readline.h" 85 ++ lib.optional (stdenv.hostPlatform.isStatic) "--disable-shared"; 86 87 env.NIX_CFLAGS_COMPILE = toString [ 88 "-DSQLITE_ENABLE_COLUMN_METADATA" 89 "-DSQLITE_ENABLE_DBSTAT_VTAB" 90 "-DSQLITE_ENABLE_JSON1" 91 "-DSQLITE_ENABLE_FTS3" 92 "-DSQLITE_ENABLE_FTS3_PARENTHESIS" 93 "-DSQLITE_ENABLE_FTS3_TOKENIZER" 94 "-DSQLITE_ENABLE_FTS4" 95 "-DSQLITE_ENABLE_FTS5" 96 "-DSQLITE_ENABLE_GEOPOLY" 97 "-DSQLITE_ENABLE_MATH_FUNCTIONS" 98 "-DSQLITE_ENABLE_PREUPDATE_HOOK" 99 "-DSQLITE_ENABLE_RBU" 100 "-DSQLITE_ENABLE_RTREE" 101 "-DSQLITE_ENABLE_SESSION" 102 "-DSQLITE_ENABLE_STMT_SCANSTATUS" 103 "-DSQLITE_ENABLE_UNLOCK_NOTIFY" 104 "-DSQLITE_SOUNDEX" 105 "-DSQLITE_SECURE_DELETE" 106 "-DSQLITE_MAX_VARIABLE_NUMBER=250000" 107 "-DSQLITE_MAX_EXPR_DEPTH=10000" 108 ]; 109 110 # Test for features which may not be available at compile time 111 preBuild = '' 112 # Necessary for FTS5 on Linux 113 export NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -lm" 114 115 echo "" 116 echo "NIX_CFLAGS_COMPILE = $NIX_CFLAGS_COMPILE" 117 echo "" 118 ''; 119 120 postInstall = '' 121 mkdir -p $doc/share/doc 122 unzip $docsrc 123 mv sqlite-doc-${archiveVersion version} $doc/share/doc/sqlite 124 ''; 125 126 doCheck = false; # fails to link against tcl 127 128 passthru = { 129 tests = { 130 inherit (python3Packages) sqlalchemy; 131 inherit 132 sqldiff 133 sqlite-analyzer 134 sqlite-rsync 135 tinysparql 136 ; 137 }; 138 139 updateScript = gitUpdater { 140 # No nicer place to look for latest version. 141 url = "https://github.com/sqlite/sqlite.git"; 142 # Expect tags like "version-3.43.0". 143 rev-prefix = "version-"; 144 }; 145 }; 146 147 meta = with lib; { 148 changelog = "https://www.sqlite.org/releaselog/${lib.replaceStrings [ "." ] [ "_" ] version}.html"; 149 description = "Self-contained, serverless, zero-configuration, transactional SQL database engine"; 150 downloadPage = "https://sqlite.org/download.html"; 151 homepage = "https://www.sqlite.org/"; 152 license = licenses.publicDomain; 153 mainProgram = "sqlite3"; 154 maintainers = with maintainers; [ np ]; 155 platforms = platforms.unix ++ platforms.windows; 156 pkgConfigModules = [ "sqlite3" ]; 157 }; 158}