From 395d9cc54ebf8f020b89abf729a989bbc13d90ea Mon Sep 17 00:00:00 2001
From: CrazyChaoz <kempinger@ins.jku.at>
Date: Mon, 25 Nov 2024 19:40:54 +0100
Subject: [PATCH] update readme

---
 README.md  |  9 ++++++++
 flake.lock | 60 ------------------------------------------------------
 flake.nix  | 57 ++++-----------------------------------------------
 3 files changed, 13 insertions(+), 113 deletions(-)

diff --git a/README.md b/README.md
index c3954ebe..5ee398ba 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,15 @@
 This crates provides TensorFlow Lite APIs.
 Please read the [`API documentation on docs.rs`](https://docs.rs/crate/tflite)
 
+# Compatibility
+
+This fork is only tested with 
+- a prebuilt `libtensorflowlite.so`
+- tensorflow `v2.13.0`
+- flatbuffers `v23.1.21`
+
+For a working example check out the nix devshell using `nix develop`
+
 ### Using the interpreter from a model file
 
 The following example shows how to use the TensorFlow Lite interpreter when provided a TensorFlow Lite FlatBuffer file.
diff --git a/flake.lock b/flake.lock
index 7d250ae5..f9cca895 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,46 +1,5 @@
 {
   "nodes": {
-    "fenix": {
-      "inputs": {
-        "nixpkgs": [
-          "nixpkgs"
-        ],
-        "rust-analyzer-src": "rust-analyzer-src"
-      },
-      "locked": {
-        "lastModified": 1732170943,
-        "narHash": "sha256-3qmtB25X5nxaaDL2VNlWB6OAQGVGv7xRm9tFMgJ3Jlo=",
-        "owner": "nix-community",
-        "repo": "fenix",
-        "rev": "7db16a01bca24b46acc1677f2b86ae03b5f207f8",
-        "type": "github"
-      },
-      "original": {
-        "owner": "nix-community",
-        "repo": "fenix",
-        "type": "github"
-      }
-    },
-    "naersk": {
-      "inputs": {
-        "nixpkgs": [
-          "nixpkgs"
-        ]
-      },
-      "locked": {
-        "lastModified": 1721727458,
-        "narHash": "sha256-r/xppY958gmZ4oTfLiHN0ZGuQ+RSTijDblVgVLFi1mw=",
-        "owner": "nix-community",
-        "repo": "naersk",
-        "rev": "3fb418eaf352498f6b6c30592e3beb63df42ef11",
-        "type": "github"
-      },
-      "original": {
-        "owner": "nix-community",
-        "repo": "naersk",
-        "type": "github"
-      }
-    },
     "nixpkgs": {
       "locked": {
         "lastModified": 1732014248,
@@ -58,29 +17,10 @@
     },
     "root": {
       "inputs": {
-        "fenix": "fenix",
-        "naersk": "naersk",
         "nixpkgs": "nixpkgs",
         "utils": "utils"
       }
     },
-    "rust-analyzer-src": {
-      "flake": false,
-      "locked": {
-        "lastModified": 1732050317,
-        "narHash": "sha256-G5LUEOC4kvB/Xbkglv0Noi04HnCfryur7dVjzlHkgpI=",
-        "owner": "rust-lang",
-        "repo": "rust-analyzer",
-        "rev": "c0bbbb3e5d7d1d1d60308c8270bfd5b250032bb4",
-        "type": "github"
-      },
-      "original": {
-        "owner": "rust-lang",
-        "ref": "nightly",
-        "repo": "rust-analyzer",
-        "type": "github"
-      }
-    },
     "systems": {
       "locked": {
         "lastModified": 1681028828,
diff --git a/flake.nix b/flake.nix
index 2b0e983a..81ba9624 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,80 +1,31 @@
 {
   inputs = {
-    fenix = {
-      url = "github:nix-community/fenix";
-      inputs.nixpkgs.follows = "nixpkgs";
-    };
-    naersk = {
-      url = "github:nix-community/naersk";
-      inputs.nixpkgs.follows = "nixpkgs";
-    };
     nixpkgs.url = "nixpkgs/nixos-unstable";
     utils = {
       url = "github:numtide/flake-utils";
     };
   };
 
-  outputs = { self, naersk, fenix, nixpkgs, utils }:
+  outputs = { self, nixpkgs, utils }:
     utils.lib.eachDefaultSystem (system:
       let
         pkgs = import nixpkgs { inherit system; };
-
-        fixed-tensorflow-lite = (pkgs.tensorflow-lite).overrideAttrs (self: super: { meta.knownVulnerabilities = [ ]; });
-
-
-        stdenv = pkgs.clangStdenv;
-
-        toolchain = with fenix.packages.${system}; combine [
-          minimal.cargo
-          minimal.rustc
-        ];
-        pname = "tflite-rs";
-
-        renamed_tflite = stdenv.mkDerivation {
-          name = "renamed_tflite";
-          src = fixed-tensorflow-lite;
-          buildPhase = ''
-            mkdir $out/
-            mkdir $out/lib/
-
-            # Copy everything except for specific files in lib/
-            cp -r $src/* $out/
-
-            # Rename specific files in lib/
-            if [ -d $out/lib ]; then
-              # Rename libtensorflowlite_c.so to libtensorflow-lite_c.so
-              if [ -f $out/lib/libtensorflowlite_c.so ]; then
-                cp $out/lib/libtensorflowlite_c.so $out/lib/libtensorflow-lite_c.so
-              fi
-
-              # Rename libtensorflowlite.so to libtensorflow-lite.so
-              if [ -f $out/lib/libtensorflowlite.so ]; then
-                cp $out/lib/libtensorflowlite.so $out/lib/libtensorflow-lite.so
-              fi
-            fi
-          '';
-        };
-
       in
       {
         devShell = pkgs.mkShell {
-          TFLITE_X86_64_LIB_DIR = "${fixed-tensorflow-lite}/lib";
-          TFLITE_LIB_DIR = "${fixed-tensorflow-lite}/lib";
+          TFLITE_X86_64_LIB_DIR = "${pkgs.tensorflow-lite}/lib";
+          TFLITE_LIB_DIR = "${pkgs.tensorflow-lite}/lib";
           LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
           buildInputs = with pkgs;[
             clang
-            llvmPackages.libclang.lib
           ];
           nativeBuildInputs = with pkgs; [
             rustc
             cargo
-            fixed-tensorflow-lite
+            tensorflow-lite
             pkg-config
-            opencv
-            perl
             clang
             libclang
-            vtk
             rustPlatform.bindgenHook
           ];
         };