diff --git a/flake.nix b/flake.nix index a31b660..3e19706 100644 --- a/flake.nix +++ b/flake.nix @@ -35,8 +35,9 @@ enableInteractive; }; in { - "sqlite-amalgamation${result.suffix}" = result.amalgamation; "sqlite${result.suffix}" = result.sqlite; + "sqlite-amalgamation${result.suffix}" = result.amalgamation; + "sqlite-cli${result.suffix}" = result.sqlite-cli; "sqlite-static${result.suffix}" = result.sqlite-static; }) productVars)); }; diff --git a/src/mk-sqlite.nix b/src/mk-sqlite.nix index f98a2f4..e761e05 100644 --- a/src/mk-sqlite.nix +++ b/src/mk-sqlite.nix @@ -71,7 +71,11 @@ in { static = true; } // config); - # "sqlite-cli" + sqlite-cli = pkgs.callPackage ./sqlite-cli.nix ({ + inherit (pkgs.sqlite) version src; + inherit amalgamate; + nameSuffix = suffix; + } // config); } // lib.optionalAttrs amalgamate { amalgamation = pkgs.callPackage ./amalgamation.nix ({ inherit (pkgs.sqlite) version src; diff --git a/src/sqlite-cli.nix b/src/sqlite-cli.nix new file mode 100644 index 0000000..411867e --- /dev/null +++ b/src/sqlite-cli.nix @@ -0,0 +1,64 @@ +{ + 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=${placeholder "out"}/bin" + "--mandir=${placeholder "out"}/share/man" + "--includedir=/tmp" + "--libdir=/tmp" + + "--disable-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"; +})