nextcloud30Packages.apps.recognize: make tensorflow optional
For non-supported systems or those who want to use WebAssembly
pkgs.nextcloud30Packages.apps.recognize.override ({ useLibTensorflow = false; });
This commit is contained in:
@@ -6,40 +6,47 @@
|
||||
python311,
|
||||
util-linux,
|
||||
ffmpeg,
|
||||
|
||||
# Current derivation only suports linux-x86_64 (contributions welcome, without libTensorflow builtin webassembly can be used)
|
||||
useLibTensorflow ? stdenv.isx86_64 && stdenv.isLinux,
|
||||
}:
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "nextcloud-app-recognise";
|
||||
version = "8.1.1";
|
||||
|
||||
srcs = [
|
||||
(fetchurl {
|
||||
inherit version;
|
||||
url = "https://github.com/nextcloud/recognize/releases/download/v${version}/recognize-${version}.tar.gz";
|
||||
hash = "sha256-RIa2HzX2hfgS7KHGGBsxEdUCqDqXeAs3Xi288qA1gU4=";
|
||||
})
|
||||
srcs =
|
||||
[
|
||||
(fetchurl {
|
||||
inherit version;
|
||||
url = "https://github.com/nextcloud/recognize/releases/download/v${version}/recognize-${version}.tar.gz";
|
||||
hash = "sha256-RIa2HzX2hfgS7KHGGBsxEdUCqDqXeAs3Xi288qA1gU4=";
|
||||
})
|
||||
|
||||
(fetchurl {
|
||||
inherit version;
|
||||
url = "https://github.com/nextcloud/recognize/archive/refs/tags/v${version}.tar.gz";
|
||||
hash = "sha256-op1Fdm40d8V6V+rfne0ECr60xRjBYrBPrCD3kaNeFfY=";
|
||||
})
|
||||
(fetchurl rec {
|
||||
# For version see LIBTENSORFLOW_VERSION in https://github.com/tensorflow/tfjs/blob/master/tfjs-node/scripts/deps-constants.js
|
||||
version = "2.9.1";
|
||||
url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-${version}.tar.gz";
|
||||
hash = "sha256-f1ENJUbj214QsdEZRjaJAD1YeEKJKtPJW8pRz4KCAXM=";
|
||||
})
|
||||
(fetchurl {
|
||||
inherit version;
|
||||
url = "https://github.com/nextcloud/recognize/archive/refs/tags/v${version}.tar.gz";
|
||||
hash = "sha256-op1Fdm40d8V6V+rfne0ECr60xRjBYrBPrCD3kaNeFfY=";
|
||||
})
|
||||
]
|
||||
++ lib.optionals useLibTensorflow [
|
||||
(fetchurl rec {
|
||||
# For version see LIBTENSORFLOW_VERSION in https://github.com/tensorflow/tfjs/blob/master/tfjs-node/scripts/deps-constants.js
|
||||
version = "2.9.1";
|
||||
url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-${version}.tar.gz";
|
||||
hash = "sha256-f1ENJUbj214QsdEZRjaJAD1YeEKJKtPJW8pRz4KCAXM=";
|
||||
})
|
||||
];
|
||||
|
||||
];
|
||||
|
||||
unpackPhase = ''
|
||||
# Merge the app and the models from github
|
||||
tar -xzpf "${builtins.elemAt srcs 0}" recognize;
|
||||
tar -xzpf "${builtins.elemAt srcs 1}" -C recognize --strip-components=1 recognize-${version}/models
|
||||
|
||||
# Place the tensorflow lib at the right place for building
|
||||
tar -xzpf "${builtins.elemAt srcs 2}" -C recognize/node_modules/@tensorflow/tfjs-node/deps
|
||||
'';
|
||||
unpackPhase =
|
||||
''
|
||||
# Merge the app and the models from github
|
||||
tar -xzpf "${builtins.elemAt srcs 0}" recognize;
|
||||
tar -xzpf "${builtins.elemAt srcs 1}" -C recognize --strip-components=1 recognize-${version}/models
|
||||
''
|
||||
+ lib.optionalString useLibTensorflow ''
|
||||
# Place the tensorflow lib at the right place for building
|
||||
tar -xzpf "${builtins.elemAt srcs 2}" -C recognize/node_modules/@tensorflow/tfjs-node/deps
|
||||
'';
|
||||
|
||||
patchPhase = ''
|
||||
# Make it clear we are not reading the node in settings
|
||||
@@ -68,7 +75,7 @@ stdenv.mkDerivation rec {
|
||||
python311
|
||||
util-linux
|
||||
];
|
||||
buildPhase = ''
|
||||
buildPhase = lib.optionalString useLibTensorflow ''
|
||||
cd recognize
|
||||
|
||||
# Install tfjs dependency
|
||||
|
||||
Reference in New Issue
Block a user