From ff0c6adf9425bfe831f6feb55dae64b5c4c0b93b Mon Sep 17 00:00:00 2001 From: h7x4 Date: Mon, 18 May 2026 21:25:28 +0900 Subject: [PATCH] Add static build --- flake.nix | 3 ++- src/mk-sqlite.nix | 8 +++++++- src/sqlite.nix | 9 ++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/flake.nix b/flake.nix index 1d6f10a..a31b660 100644 --- a/flake.nix +++ b/flake.nix @@ -35,8 +35,9 @@ enableInteractive; }; in { - # "sqlite-amalgamation${result.suffix}" = result.amalgamation; + "sqlite-amalgamation${result.suffix}" = result.amalgamation; "sqlite${result.suffix}" = result.sqlite; + "sqlite-static${result.suffix}" = result.sqlite-static; }) productVars)); }; } diff --git a/src/mk-sqlite.nix b/src/mk-sqlite.nix index 6138527..f98a2f4 100644 --- a/src/mk-sqlite.nix +++ b/src/mk-sqlite.nix @@ -61,9 +61,15 @@ in { inherit (pkgs.sqlite) version src; inherit amalgamate; nameSuffix = suffix; + static = false; } // config); - # "sqlite-static" + sqlite-static = pkgs.callPackage ./sqlite.nix ({ + inherit (pkgs.sqlite) version src; + inherit amalgamate; + nameSuffix = suffix; + static = true; + } // config); # "sqlite-cli" } // lib.optionalAttrs amalgamate { diff --git a/src/sqlite.nix b/src/sqlite.nix index ca53d90..ed4b054 100644 --- a/src/sqlite.nix +++ b/src/sqlite.nix @@ -1,6 +1,8 @@ { lib, + static ? false, + src, version, nameSuffix, @@ -45,11 +47,12 @@ stdenv.mkDerivation (finalAttrs: { configureFlags = [ "--bindir=/tmp" + "--mandir=/tmp" "--includedir=${placeholder "out"}/include" "--libdir=${placeholder "out"}/lib" - "--enable-shared" - "--disable-static" + "--${if static then "disable" else "enable"}-shared" + "--${if static then "enable" else "disable"}-static" "--${if amalgamate then "enable" else "disable"}-amalgamation" ] ++ lib.optional features.ENABLE_ICU [ "--enable-icu-collations" @@ -59,5 +62,5 @@ stdenv.mkDerivation (finalAttrs: { env.NIX_CFLAGS_COMPILE = lib.concatStringsSep " " featureFlags; env.NIX_CFLAGS_LINK = lib.optionalString features.ENABLE_FTS5 "-lm"; - makeTarget = "sqlite3.so"; + makeTarget = "sqlite3.la"; })