diff --git a/flake.nix b/flake.nix index 16a50dd..1d6f10a 100644 --- a/flake.nix +++ b/flake.nix @@ -35,7 +35,8 @@ enableInteractive; }; in { - "sqlite-amalgamation${result.suffix}" = result.amalgamation; + # "sqlite-amalgamation${result.suffix}" = result.amalgamation; + "sqlite${result.suffix}" = result.sqlite; }) productVars)); }; } diff --git a/src/amalgamation.nix b/src/amalgamation.nix index 98ab913..360e384 100644 --- a/src/amalgamation.nix +++ b/src/amalgamation.nix @@ -9,8 +9,7 @@ unzip, zlib, - readline, - ncurses, + icu, features, featureFlags, @@ -29,10 +28,8 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ zlib - ] - ++ lib.optionals enableInteractive [ - readline - ncurses + ] ++ lib.optional features.ENABLE_ICU [ + icu ]; # required for aarch64 but applied for all arches for simplicity @@ -45,10 +42,10 @@ stdenv.mkDerivation (finalAttrs: { # on a per-output basis. setOutputFlags = false; - configureFlags = - lib.optional (!enableInteractive) "--disable-readline" - # autosetup only looks up readline.h in predefined set of directories. - ++ lib.optional enableInteractive "--with-readline-header=${lib.getDev readline}/include/readline/readline.h"; + configureFlags = lib.optional features.ENABLE_ICU [ + "--enable-icu-collations" + "--with-icu-config=${lib.getExe' icu.dev "icu-config"}" + ]; env.NIX_CFLAGS_COMPILE = lib.concatStringsSep " " featureFlags; env.NIX_CFLAGS_LINK = lib.optionalString features.ENABLE_FTS5 "-lm"; diff --git a/src/mk-sqlite.nix b/src/mk-sqlite.nix index c56e8ee..6138527 100644 --- a/src/mk-sqlite.nix +++ b/src/mk-sqlite.nix @@ -57,8 +57,15 @@ in { inherit config; inherit suffix; - # "sqlite" + sqlite = pkgs.callPackage ./sqlite.nix ({ + inherit (pkgs.sqlite) version src; + inherit amalgamate; + nameSuffix = suffix; + } // config); + # "sqlite-static" + + # "sqlite-cli" } // lib.optionalAttrs amalgamate { amalgamation = pkgs.callPackage ./amalgamation.nix ({ inherit (pkgs.sqlite) version src; diff --git a/src/sqlite.nix b/src/sqlite.nix new file mode 100644 index 0000000..ca53d90 --- /dev/null +++ b/src/sqlite.nix @@ -0,0 +1,63 @@ +{ + lib, + + src, + version, + nameSuffix, + + stdenv, + + unzip, + zlib, + icu, + + amalgamate, + features, + featureFlags, + enableInteractive ? false, + + ... +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "sqlite${nameSuffix}"; + inherit version src; + + nativeBuildInputs = [ + unzip + ]; + + buildInputs = [ + zlib + ] ++ lib.optional features.ENABLE_ICU [ + icu + ]; + + # required for aarch64 but applied for all arches for simplicity + preConfigure = '' + patchShebangs configure + ''; + + # sqlite relies on autosetup now; so many of the + # previously-understood flags are gone. They should instead be set + # on a per-output basis. + setOutputFlags = false; + + configureFlags = [ + "--bindir=/tmp" + "--includedir=${placeholder "out"}/include" + "--libdir=${placeholder "out"}/lib" + + "--enable-shared" + "--disable-static" + "--${if amalgamate then "enable" else "disable"}-amalgamation" + ] ++ lib.optional features.ENABLE_ICU [ + "--enable-icu-collations" + "--with-icu-config=${lib.getExe' icu.dev "icu-config"}" + ]; + + env.NIX_CFLAGS_COMPILE = lib.concatStringsSep " " featureFlags; + env.NIX_CFLAGS_LINK = lib.optionalString features.ENABLE_FTS5 "-lm"; + + makeTarget = "sqlite3.so"; +})