feat: Added nix build support
Some checks failed
build / checks-matrix (push) Successful in 19m19s
build / codecov (push) Failing after 19m26s
docs / docs (push) Has been cancelled
build / checks-build (push) Has been cancelled

This commit is contained in:
uttarayan21
2025-08-19 14:30:43 +05:30
parent cd12e97de3
commit 3d56db687c
3 changed files with 23 additions and 22 deletions

16
Cargo.lock generated
View File

@@ -1312,7 +1312,7 @@ dependencies = [
[[package]]
name = "mnn-bridge"
version = "0.1.0"
source = "git+https://github.com/uttarayan21/mnn-rs?branch=restructure-tensor-type#f972f1eb903d6ae38f1f1c409a01559282f2f036"
source = "git+https://github.com/uttarayan21/mnn-rs?branch=restructure-tensor-type#456c53307ff551d8cb8e4e380c7febf7c16ba0ab"
dependencies = [
"error-stack",
"mnn",
@@ -1322,7 +1322,7 @@ dependencies = [
[[package]]
name = "mnn-sync"
version = "0.1.0"
source = "git+https://github.com/uttarayan21/mnn-rs?branch=restructure-tensor-type#f972f1eb903d6ae38f1f1c409a01559282f2f036"
source = "git+https://github.com/uttarayan21/mnn-rs?branch=restructure-tensor-type#456c53307ff551d8cb8e4e380c7febf7c16ba0ab"
dependencies = [
"error-stack",
"flume",
@@ -1594,6 +1594,8 @@ dependencies = [
[[package]]
name = "ort"
version = "2.0.0-rc.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fa7e49bd669d32d7bc2a15ec540a527e7764aec722a45467814005725bcd721"
dependencies = [
"ndarray",
"ort-sys",
@@ -1604,6 +1606,8 @@ dependencies = [
[[package]]
name = "ort-sys"
version = "2.0.0-rc.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2aba9f5c7c479925205799216e7e5d07cc1d4fa76ea8058c60a9a30f6a4e890"
dependencies = [
"pkg-config",
]
@@ -1692,9 +1696,9 @@ dependencies = [
[[package]]
name = "prettyplease"
version = "0.2.36"
version = "0.2.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff24dfcda44452b9816fff4cd4227e1bb73ff5a2f1bc1105aa92fb8565ce44d2"
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
dependencies = [
"proc-macro2",
"syn",
@@ -2011,9 +2015,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.142"
version = "1.0.143"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7"
checksum = "d401abef1d108fbd9cbaebc3e46611f4b1021f714a0597a71f41ee463f5f4a5a"
dependencies = [
"itoa",
"memchr",

View File

@@ -7,9 +7,6 @@ edition = "2024"
[patch."https://github.com/uttarayan21/mnn-rs"]
mnn = { path = "/Users/fs0c131y/Projects/aftershoot/mnn-rs" }
[patch.crates-io]
ort = { path = "/Users/fs0c131y/Projects/ort" }
[workspace.dependencies]
ndarray-image = { path = "ndarray-image" }

View File

@@ -78,6 +78,14 @@
craneLib = (crane.mkLib pkgs).overrideToolchain stableToolchain;
craneLibLLvmTools = (crane.mkLib pkgs).overrideToolchain stableToolchainWithLLvmTools;
ort_static = pkgs.onnxruntime.overrideAttrs (old: {
cmakeFlags =
old.cmakeFlags
++ [
"-Donnxruntime_BUILD_SHARED_LIB=OFF"
"-Donnxruntime_BUILD_STATIC_LIB=ON"
];
});
src = let
filterBySuffix = path: exts: lib.any (ext: lib.hasSuffix ext path) exts;
sourceFilters = path: type:
@@ -96,25 +104,16 @@
filter = sourceFilters;
src = ./.;
};
commonArgs = let
ort_static = pkgs.onnxruntime.overrideAttrs (old: {
cmakeFlags =
old.cmakeFlags
++ [
"-Donnxruntime_BUILD_SHARED_LIB=OFF"
"-Donnxruntime_BUILD_STATIC_LIB=ON"
];
});
in
commonArgs =
{
inherit src;
pname = name;
stdenv = p: p.clangStdenv;
doCheck = false;
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
ORT_LIB_LOCATION = "${ort_static}";
ORT_ENV_SYSTEM_LIB_LOCATION = "${ort_static}/lib";
# ORT_ENV_PREFER_DYNAMIC_LINK = true;
ORT_LIB_LOCATION = "${pkgs.onnxruntime}";
ORT_ENV_SYSTEM_LIB_LOCATION = "${pkgs.onnxruntime}/lib";
ORT_ENV_PREFER_DYNAMIC_LINK = true;
nativeBuildInputs = with pkgs; [
cmake
pkg-config
@@ -192,6 +191,7 @@
in {
"${name}" = pkg;
default = pkg;
onnxruntime = ort_static;
};
devShells = {