111 lines
2.9 KiB
Nix
111 lines
2.9 KiB
Nix
{
|
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
outputs = { self, nixpkgs }:
|
|
let
|
|
inherit (nixpkgs) lib;
|
|
|
|
systems = [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
"x86_64-darwin"
|
|
"aarch64-darwin"
|
|
];
|
|
|
|
forAllSystems = f: lib.genAttrs systems (system: f system nixpkgs.legacyPackages.${system});
|
|
in {
|
|
mkSqlite = import ./src/mk-sqlite.nix { inherit lib; };
|
|
|
|
packages = forAllSystems (system: pkgs: let
|
|
productVars = {
|
|
enableMinimal = [ true false ];
|
|
enableDebug = [ true false ];
|
|
enableInteractive = [ true false ];
|
|
};
|
|
in lib.mergeAttrsList (lib.mapCartesianProduct ({
|
|
enableMinimal,
|
|
enableDebug,
|
|
enableInteractive,
|
|
}: let
|
|
result = self.mkSqlite {
|
|
inherit
|
|
pkgs
|
|
enableMinimal
|
|
enableDebug
|
|
enableInteractive;
|
|
};
|
|
in {
|
|
"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));
|
|
|
|
checks = forAllSystems (system: pkgs: let
|
|
sqlite-example-exts-static = pkgs.stdenv.mkDerivation {
|
|
name = "sqlite-example-exts-static";
|
|
src = ./sqlite-example-exts;
|
|
|
|
env.NIX_CFLAGS_COMPILE = "-DSQLITE_CORE";
|
|
|
|
buildInputs = with pkgs; [ sqlite.dev ];
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
|
|
"$CC" -c addext.c
|
|
"$AR" rcs libaddext.a addext.o
|
|
|
|
"$CC" -c subext.c
|
|
"$AR" rcs libsubext.a subext.o
|
|
|
|
"$CC" -c multext.c
|
|
"$AR" rcs libmultext.a multext.o
|
|
|
|
runHook postBuild
|
|
'';
|
|
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
install -Dm444 *.a -t "$out/lib"
|
|
|
|
runHook postInstall
|
|
'';
|
|
};
|
|
|
|
sqlite-with-static-exts = self.mkSqlite {
|
|
inherit pkgs;
|
|
|
|
extensions = [
|
|
{
|
|
library = "${sqlite-example-exts-static}/lib/libaddext.a";
|
|
init = "sqlite3_addext_init";
|
|
}
|
|
{
|
|
library = "${sqlite-example-exts-static}/lib/libsubext.a";
|
|
init = "sqlite3_subext_init";
|
|
}
|
|
{
|
|
library = "${sqlite-example-exts-static}/lib/libmultext.a";
|
|
init = "sqlite3_multext_init";
|
|
}
|
|
];
|
|
};
|
|
in {
|
|
checkExts = pkgs.runCommand "test-sqlite-with-static-exts" {
|
|
nativeBuildInputs = [ sqlite-with-static-exts.sqlite-cli ];
|
|
|
|
passthru = {
|
|
inherit sqlite-example-exts-static;
|
|
inherit sqlite-with-static-exts;
|
|
};
|
|
} ''
|
|
mkdir -p "$out"
|
|
sqlite3 :memory: <<<"SELECT myadd(1, 2), mysub(5, 3), mymult(4, 6);" | tee "$out/test.log"
|
|
grep -q -F "3|2|24" "$out/test.log" || (echo "Unexpected output from sqlite3 with static extensions" && exit 1)
|
|
'';
|
|
});
|
|
};
|
|
}
|