diff --git a/flake.lock b/flake.lock index 8630388..3ab2654 100644 --- a/flake.lock +++ b/flake.lock @@ -15,6 +15,27 @@ "type": "github" } }, + "nix-sqlite": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1779411945, + "narHash": "sha256-8aCvP/VXmhephNNTlpjKApCV1Qf4Uq/j/KBSPq6KFes=", + "ref": "main", + "rev": "8d0ea0b23b2f8bcddc9fbbd4cec2e1c00090dde1", + "revCount": 20, + "type": "git", + "url": "https://git.pvv.ntnu.no/mugiten/nix-custom-sqlite.git" + }, + "original": { + "ref": "main", + "type": "git", + "url": "https://git.pvv.ntnu.no/mugiten/nix-custom-sqlite.git" + } + }, "nixpkgs": { "locked": { "lastModified": 1778869304, @@ -34,6 +55,7 @@ "root": { "inputs": { "crane": "crane", + "nix-sqlite": "nix-sqlite", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay" } diff --git a/flake.nix b/flake.nix index 9a30004..244d8e5 100644 --- a/flake.nix +++ b/flake.nix @@ -5,10 +5,13 @@ rust-overlay.url = "github:oxalica/rust-overlay"; rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; + nix-sqlite.url = "git+https://git.pvv.ntnu.no/mugiten/nix-custom-sqlite.git?ref=main"; + nix-sqlite.inputs.nixpkgs.follows = "nixpkgs"; + crane.url = "github:ipetkov/crane"; }; - outputs = { self, nixpkgs, rust-overlay, crane }: + outputs = { self, nixpkgs, rust-overlay, nix-sqlite, crane }: let inherit (nixpkgs) lib; @@ -119,6 +122,31 @@ ]; }; + tamerye-static-lib-android = androidPkgs.rustPlatform.buildRustPackage { + pname = "tamerye-static-lib-android"; + version = cargoToml.package.version; + inherit src; + + inherit cargoLock; + + strictDeps = true; + doCheck = false; + + nativeBuildInputs = with androidPkgs; [ + rustfmt + ]; + + postPatch = '' + '${lib.getExe pkgs.yq-go}' '.lib.crate-type = [ "staticlib" ]' --inplace Cargo.toml + ''; + + buildInputs = with pkgs; [ + sqlite + ]; + + cargoExtraArgs = lib.escapeShellArgs [ "--features" "static" ]; + }; + tamerye-shared-lib-crane = craneLib.buildPackage { pname = "tamerye-shared-lib"; version = cargoToml.package.version; @@ -186,6 +214,31 @@ partitionType = "count"; cargoNextestPartitionsExtraArgs = "--no-tests=pass"; }; + + sqlite-tamerye-static = let + custom-sqlite = nix-sqlite.mkSqlite { + inherit pkgs; + enableInteractive = true; + # features = { + # ENABLE_COLUMN_METADATA = true; + # }; + extensions = [{ + library = "${self.packages.${system}.tamerye-static-lib-crane}/lib/libtamerye.a"; + init = "sqlite3_tamerye_init"; + }]; + }; + in custom-sqlite.sqlite-cli; + + sqlite-tamerye-static-android = let + custom-sqlite = nix-sqlite.mkSqlite { + pkgs = androidPkgs; + enableInteractive = true; + extensions = [{ + library = "${self.packages.${system}.tamerye-static-lib-android}/lib/libtamerye.a"; + init = "sqlite3_tamerye_init"; + }]; + }; + in custom-sqlite.sqlite; }); }; }