nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 166 lines 4.5 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 unzip, 6 tcl, 7 zlib, 8 readline, 9 ncurses, 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 buildPackages, 23}: 24 25let 26 archiveVersion = import ./archive-version.nix lib; 27in 28 29stdenv.mkDerivation rec { 30 pname = "sqlite${lib.optionalString interactive "-interactive"}"; 31 version = "3.51.2"; 32 33 # nixpkgs-update: no auto update 34 # NB! Make sure to update ./tools.nix src (in the same directory). 35 src = fetchurl { 36 url = "https://sqlite.org/2026/sqlite-src-${archiveVersion version}.zip"; 37 hash = "sha256-hREPdi1QeUFNmd1deRe8P/fgWHbmzL0T2ElqOBfyCCk="; 38 }; 39 docsrc = fetchurl { 40 url = "https://sqlite.org/2026/sqlite-doc-${archiveVersion version}.zip"; 41 hash = "sha256-xuMNB8XpwSaQHFTY18kKnBo3B4JFUX8GCzxpxN5Dv10="; 42 }; 43 44 outputs = [ 45 "bin" 46 "dev" 47 "man" 48 "doc" 49 "out" 50 ]; 51 separateDebugInfo = stdenv.hostPlatform.isLinux; 52 53 depsBuildBuild = [ 54 buildPackages.stdenv.cc 55 ]; 56 57 nativeBuildInputs = [ 58 unzip 59 tcl 60 ]; 61 buildInputs = [ 62 zlib 63 ] 64 ++ lib.optionals interactive [ 65 readline 66 ncurses 67 ]; 68 69 # required for aarch64 but applied for all arches for simplicity 70 preConfigure = '' 71 patchShebangs configure 72 ''; 73 74 # sqlite relies on autosetup now; so many of the 75 # previously-understood flags are gone. They should instead be set 76 # on a per-output basis. 77 setOutputFlags = false; 78 79 env.TCLLIBDIR = "${placeholder "out"}/lib"; 80 81 configureFlags = [ 82 "--bindir=${placeholder "bin"}/bin" 83 "--includedir=${placeholder "dev"}/include" 84 "--libdir=${placeholder "out"}/lib" 85 (if stdenv.hostPlatform.isStatic then "--disable-tcl" else "--with-tcl=${lib.getLib tcl}/lib") 86 ] 87 ++ lib.optional (!interactive) "--disable-readline" 88 # autosetup only looks up readline.h in predefined set of directories. 89 ++ lib.optional interactive "--with-readline-header=${lib.getDev readline}/include/readline/readline.h" 90 ++ lib.optional (stdenv.hostPlatform.isStatic) "--disable-shared"; 91 92 env.NIX_CFLAGS_COMPILE = toString [ 93 "-DSQLITE_ENABLE_COLUMN_METADATA" 94 "-DSQLITE_ENABLE_DBSTAT_VTAB" 95 "-DSQLITE_ENABLE_JSON1" 96 "-DSQLITE_ENABLE_FTS3" 97 "-DSQLITE_ENABLE_FTS3_PARENTHESIS" 98 "-DSQLITE_ENABLE_FTS3_TOKENIZER" 99 "-DSQLITE_ENABLE_FTS4" 100 "-DSQLITE_ENABLE_FTS5" 101 "-DSQLITE_ENABLE_GEOPOLY" 102 "-DSQLITE_ENABLE_MATH_FUNCTIONS" 103 "-DSQLITE_ENABLE_PREUPDATE_HOOK" 104 "-DSQLITE_ENABLE_RBU" 105 "-DSQLITE_ENABLE_RTREE" 106 "-DSQLITE_ENABLE_SESSION" 107 "-DSQLITE_ENABLE_STMT_SCANSTATUS" 108 "-DSQLITE_ENABLE_UNLOCK_NOTIFY" 109 "-DSQLITE_SOUNDEX" 110 "-DSQLITE_SECURE_DELETE" 111 "-DSQLITE_MAX_VARIABLE_NUMBER=250000" 112 "-DSQLITE_MAX_EXPR_DEPTH=10000" 113 ]; 114 115 # Test for features which may not be available at compile time 116 preBuild = '' 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 # SQLite’s tests are unreliable on Darwin. Sometimes they run successfully, but often they do not. 132 doCheck = !stdenv.hostPlatform.isDarwin; 133 # When tcl is not available, only run test targets that don't need it. 134 checkTarget = lib.optionalString stdenv.hostPlatform.isStatic "fuzztest sourcetest"; 135 136 passthru = { 137 tests = { 138 inherit (python3Packages) sqlalchemy; 139 inherit 140 sqldiff 141 sqlite-analyzer 142 sqlite-rsync 143 tinysparql 144 ; 145 }; 146 147 updateScript = gitUpdater { 148 # No nicer place to look for latest version. 149 url = "https://github.com/sqlite/sqlite.git"; 150 # Expect tags like "version-3.43.0". 151 rev-prefix = "version-"; 152 }; 153 }; 154 155 meta = { 156 changelog = "https://www.sqlite.org/releaselog/${lib.replaceStrings [ "." ] [ "_" ] version}.html"; 157 description = "Self-contained, serverless, zero-configuration, transactional SQL database engine"; 158 downloadPage = "https://sqlite.org/download.html"; 159 homepage = "https://www.sqlite.org/"; 160 license = lib.licenses.publicDomain; 161 mainProgram = "sqlite3"; 162 maintainers = with lib.maintainers; [ np ]; 163 platforms = lib.platforms.unix ++ lib.platforms.windows; 164 pkgConfigModules = [ "sqlite3" ]; 165 }; 166}