Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
beardhatcode committed Nov 22, 2024
1 parent 63dedd6 commit 5043312
Showing 1 changed file with 55 additions and 4 deletions.
59 changes: 55 additions & 4 deletions pkgs/servers/nextcloud/packages/apps/recognize.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,85 @@
fetchurl,
lib,
nodejs,
python311,
python311Packages,

util-linux, # needed?
...
}:
stdenv.mkDerivation rec {
pname = "nextcloud-app-recognise";
version = "6.0.1";
version = "8.1.1";

srcs = [
(fetchurl {
inherit version;
url = "https://github.com/nextcloud/recognize/releases/download/v${version}/recognize-${version}.tar.gz";
hash = "sha256-HQHfcQY2N6INLfaLDWbWn0SSzvkSZqL0rPl2koqej6c=";
hash = "sha256-RIa2HzX2hfgS7KHGGBsxEdUCqDqXeAs3Xi288qA1gU4=";
})

(fetchurl {
inherit version;
url = "https://github.com/nextcloud/recognize/archive/refs/tags/v${version}.tar.gz";
hash = "sha256-4iJVKz/HfzIUouiOK/NUkJUm4+p9meVptQwJ4OG1JaU=";
hash = "sha256-op1Fdm40d8V6V+rfne0ECr60xRjBYrBPrCD3kaNeFfY=";
})
(fetchurl {
inherit version;
url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-2.9.1.tar.gz";
hash = "sha256-f1ENJUbj214QsdEZRjaJAD1YeEKJKtPJW8pRz4KCAXM=";
})
(fetchurl {
inherit version;
url = "https://nodejs.org/download/release/v20.15.1/node-v20.15.1-headers.tar.gz";
hash = "sha256-jCMFxt9dFFJeBxHw2jgpVgCYffTCcQxzjAFACGKhdrQ=";
})

];

unpackPhase = ''
tar -xzpf "${builtins.elemAt srcs 0}" recognize;
tar -xzpf "${builtins.elemAt srcs 1}" recognize-${version}/models;
mv recognize-${version}/models recognize
sed -i "/'node_binary'/s:'""':'${nodejs}/bin/node':" recognize/lib/Service/SettingsService.php
cd recognize/node_modules/@tensorflow/tfjs-node/deps
tar -xzpf "${builtins.elemAt srcs 2}"
cd -
#cd recognize/node_modules/@tensorflow/tfjs-node/lib
#tar -xzpf "${builtins.elemAt srcs 3}"
#cd -
# recognize/node_modules/@tensorflow/tfjs-node/deps/lib/libtensorflow.so.2.9.1
'';

buildInputs = [
nodejs
nodejs.pkgs.node-pre-gyp
nodejs.pkgs.node-gyp
python311
util-linux
python311Packages.tensorflow
];
buildPhase = ''
mkdir tmphome
export HOME="$(realpath tmphome)"
sed -i "/'node_binary'/s:'""':'${nodejs}/bin/node':" recognize/lib/Service/SettingsService.php
cd recognize
set -x
#ln -sf -t node_modules/@tensorflow/tfjs-node/deps ${python311Packages.tensorflow}/*
ls node_modules/@tensorflow/tfjs-node/deps
export CPPFLAGS="-I${nodejs}/include/node -Ideps/include -I${python311Packages.tensorflow}/lib/python3.11/site-packages/tensorflow/include"
export LDFLAGS="-L${python311Packages.tensorflow}/lib/python3.11/site-packages/tensorflow"
cd node_modules/@tensorflow/tfjs-node
echo "===="
ls deps/include
echo "==="
node-pre-gyp install --prefer-offline --build-from-source --nodedir=${nodejs}/include/node
cd -
${nodejs}/bin/node src/test_libtensorflow.js
cd ..
'';
installPhase = ''
set -x
approot="$(dirname $(dirname $(find -path '*/appinfo/info.xml' | head -n 1)))"
if [ -d "$approot" ];
then
Expand Down

0 comments on commit 5043312

Please sign in to comment.