photoprism: init at 221102-905925b4d

This commit is contained in:
Benjamin Isbarn 2022-11-02 19:41:07 +01:00 committed by Benjamin Isbarn
parent 370468638e
commit 106a616eae
No known key found for this signature in database
GPG key ID: 48E0C7E5DE3B336C
9 changed files with 7461 additions and 3919 deletions

View file

@ -247,6 +247,7 @@
, "patch-package"
, "peerflix"
, "peerflix-server"
, {"photoprism-frontend": "../../servers/photoprism"}
, "pkg"
, "pm2"
, "pnpm"

File diff suppressed because it is too large Load diff

View file

@ -364,6 +364,10 @@ final: prev: {
'';
};
photoprism-frontend = prev."photoprism-frontend-../../servers/photoprism".override {
meta.broken = true; # use the top-level package instead
};
pnpm = prev.pnpm.override {
nativeBuildInputs = [ pkgs.buildPackages.makeWrapper ];

View file

@ -0,0 +1,38 @@
{ lib, buildGoModule, coreutils, libtensorflow, src, version, ... }:
buildGoModule rec {
inherit src version;
pname = "photoprism-backend";
buildInputs = [
coreutils
libtensorflow
];
ldflags = [
"-s"
"-w"
"-X main.version=${version}"
];
postPatch = ''
substituteInPlace internal/commands/passwd.go --replace '/bin/stty' "${coreutils}/bin/stty"
'';
vendorSha256 = "sha256-x1WfBxjGg4HKnzN0xEY43hgwdS6yf1AFo3GlW8e7nrM=";
subPackages = [ "cmd/photoprism" ];
# https://github.com/mattn/go-sqlite3/issues/822
CGO_CFLAGS = "-Wno-return-local-addr";
# https://github.com/tensorflow/tensorflow/issues/43847
CGO_LDFLAGS = "-fuse-ld=gold";
meta = with lib; {
homepage = "https://photoprism.app";
description = "Photoprism's backend";
license = licenses.agpl3Only;
maintainers = with maintainers; [ benesim ];
};
}

View file

@ -0,0 +1,86 @@
{ pkgs, lib, stdenv, fetchFromGitHub, fetchzip, darktable, rawtherapee, ffmpeg, libheif, exiftool, nixosTests, makeWrapper }:
let
version = "221102-905925b4d";
pname = "photoprism";
src = fetchFromGitHub {
owner = pname;
repo = pname;
rev = version;
sha256 = "sha256-xyyV16yYlKIMINmVDtiQJmnbEQ12wjzn6p90f4+GpWk=";
};
libtensorflow = pkgs.callPackage ./libtensorflow.nix { };
backend = pkgs.callPackage ./backend.nix { inherit libtensorflow src version; };
frontend = pkgs.callPackage ./frontend.nix { inherit src version; };
fetchModel = { name, sha256 }:
fetchzip {
inherit sha256;
url = "https://dl.photoprism.org/tensorflow/${name}.zip";
stripRoot = false;
};
facenet = fetchModel {
name = "facenet";
sha256 = "sha256-aS5kkNhxOLSLTH/ipxg7NAa1w9X8iiG78jmloR1hpRo=";
};
nasnet = fetchModel {
name = "nasnet";
sha256 = "sha256-bF25jPmZLyeSWy/CGXZE/VE2UupEG2q9Jmr0+1rUYWE=";
};
nsfw = fetchModel {
name = "nsfw";
sha256 = "sha256-zy/HcmgaHOY7FfJUY6I/yjjsMPHR2Ote9ppwqemBlfg=";
};
assets_path = "$out/share/${pname}";
in
stdenv.mkDerivation {
inherit pname version;
buildInputs = [
makeWrapper
];
dontUnpack = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/bin ${assets_path}
# install backend
ln -s ${backend}/bin/photoprism $out/bin/photoprism
wrapProgram $out/bin/photoprism \
--set PHOTOPRISM_ASSETS_PATH ${assets_path} \
--set PHOTOPRISM_DARKTABLE_BIN ${darktable}/bin/darktable-cli \
--set PHOTOPRISM_RAWTHERAPEE_BIN ${rawtherapee}/bin/rawtherapee-cli \
--set PHOTOPRISM_HEIFCONVERT_BIN ${libheif}/bin/heif-convert \
--set PHOTOPRISM_FFMPEG_BIN ${ffmpeg}/bin/ffmpeg \
--set PHOTOPRISM_EXIFTOOL_BIN ${exiftool}/bin/exiftool
# install frontend
ln -s ${frontend}/assets/* ${assets_path}
# install tensorflow models
ln -s ${nasnet}/nasnet ${assets_path}
ln -s ${nsfw}/nsfw ${assets_path}
ln -s ${facenet}/facenet ${assets_path}
runHook postInstall
'';
passthru.tests.photoprism = nixosTests.photoprism;
meta = with lib; {
homepage = "https://photoprism.app";
description = "Personal Photo Management powered by Go and Google TensorFlow";
inherit (libtensorflow.meta) platforms;
license = licenses.agpl3Only;
maintainers = with maintainers; [ benesim ];
};
}

View file

@ -0,0 +1,47 @@
{ lib, nodePackages, nodejs-14_x, stdenv, src, version, ... }:
let
nodeDependencies = nodePackages.photoprism-frontend.override {
inherit version;
name = "photoprism-frontend-dependencies";
# Workaround for lack of sourceRoot option in buildNodePackage.
src = "${src}/frontend";
meta.broken = false;
};
in
stdenv.mkDerivation {
inherit src version;
pname = "photoprism-frontend";
buildInputs = [ nodejs-14_x ];
buildPhase = ''
runHook preBuild
pushd frontend
ln -s ${nodeDependencies}/lib/node_modules/photoprism/node_modules ./node_modules
export PATH="${nodeDependencies}/lib/node_modules/photoprism/node_modules/.bin:$PATH"
NODE_ENV=production npm run build
popd
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir $out
cp -r assets $out/
runHook postInstall
'';
meta = with lib; {
homepage = "https://photoprism.app";
description = "Photoprism's frontend";
license = licenses.agpl3Only;
maintainers = with maintainers; [ benesim ];
};
}

View file

@ -0,0 +1,85 @@
{ lib, stdenv, fetchurl, ... }:
let
inherit (stdenv.hostPlatform) system;
in
stdenv.mkDerivation rec {
pname = "libtensorflow-photoprism";
version = "1.15.2";
srcs = [
# Photoprism-packaged libtensorflow tarball (with pre-built libs for both arm64 and amd64)
# We need this specific version because of https://github.com/photoprism/photoprism/issues/222
(fetchurl {
sha256 = {
x86_64-linux = "sha256-bZAC3PJxqcjuGM4RcNtzYtkg3FD3SrO5beDsPoKenzc=";
aarch64-linux = "sha256-qnj4vhSWgrk8SIjzIH1/4waMxMsxMUvqdYZPaSaUJRk=";
}.${system};
url = let
systemName = {
x86_64-linux = "amd64";
aarch64-linux = "arm64";
}.${system};
in "https://dl.photoprism.app/tensorflow/${systemName}/libtensorflow-${systemName}-${version}.tar.gz";
})
# Upstream tensorflow tarball (with .h's photoprism's tarball is missing)
(fetchurl {
url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.15.0.tar.gz";
sha256 = "sha256-3sv9WnCeztNSP1XM+iOTN6h+GrPgAO/aNhfbeeEDTe0=";
})
];
sourceRoot = ".";
unpackPhase = ''
sources=($srcs)
mkdir downstream upstream
tar xf ''${sources[0]} --directory downstream
tar xf ''${sources[1]} --directory upstream
mv downstream/lib .
mv upstream/{include,LICENSE,THIRD_PARTY_TF_C_LICENSES} .
rm -r downstream upstream
cd lib
ln -sT libtensorflow.so{,.1}
ln -sT libtensorflow_framework.so{,.1}
cd ..
'';
# Patch library to use our libc, libstdc++ and others
patchPhase = let
rpath = lib.makeLibraryPath [ stdenv.cc.libc stdenv.cc.cc.lib ];
in ''
chmod -R +w lib
patchelf --set-rpath "${rpath}:$out/lib" lib/libtensorflow.so
patchelf --set-rpath "${rpath}" lib/libtensorflow_framework.so
'';
buildPhase = ''
# Write pkg-config file.
mkdir lib/pkgconfig
cat > lib/pkgconfig/tensorflow.pc << EOF
Name: TensorFlow
Version: ${version}
Description: Library for computation using data flow graphs for scalable machine learning
Requires:
Libs: -L$out/lib -ltensorflow
Cflags: -I$out/include/tensorflow
EOF
'';
installPhase = ''
mkdir -p $out
cp -r LICENSE THIRD_PARTY_TF_C_LICENSES lib include $out
'';
meta = with lib; {
homepage = "https://dl.photoprism.app/tensorflow/";
description = "Libtensorflow version for usage with photoprism backend";
platforms = [ "x86_64-linux" "aarch64-linux" ];
license = licenses.asl20;
maintainers = with maintainers; [ benesim ];
};
}

View file

@ -0,0 +1,123 @@
{
"name": "photoprism",
"version": "1.0.0",
"description": "AI-Powered Photos App",
"author": "PhotoPrism UG",
"license": "AGPL-3.0",
"private": true,
"scripts": {
"watch": "webpack --watch",
"build": "webpack --node-env=production",
"trace": "webpack --stats-children",
"debug": "webpack --stats-error-details",
"lint": "eslint --cache src/ *.js",
"fmt": "eslint --cache --fix src/ *.js .eslintrc.js",
"test": "karma start",
"upgrade": "npm --depth 10 update && npm audit fix",
"testcafe": "testcafe",
"acceptance-local": "testcafe chromium --selector-timeout 5000 -S -s tests/acceptance/screenshots tests/acceptance",
"gettext-extract": "gettext-extract --output src/locales/translations.pot $(find ${SRC:-src} -type f \\( -iname \\*.vue -o -iname \\*.js \\) -not -path src/common/vm.js)",
"gettext-compile": "gettext-compile --output src/locales/translations.json src/locales/*.po"
},
"dependencies": {
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.3",
"@babel/eslint-parser": "^7.19.1",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-object-rest-spread": "^7.19.4",
"@babel/plugin-transform-runtime": "^7.19.1",
"@babel/preset-env": "^7.19.4",
"@babel/register": "^7.18.9",
"@babel/runtime": "^7.19.4",
"@lcdp/offline-plugin": "^5.1.1",
"@vvo/tzdb": "^6.71.0",
"axios": "^0.27.2",
"axios-mock-adapter": "^1.21.2",
"babel-loader": "^8.2.5",
"babel-plugin-istanbul": "^6.1.1",
"browserslist": "^4.21.4",
"chai": "^4.3.6",
"cheerio": "1.0.0-rc.10",
"chrome-finder": "^1.0.7",
"core-js": "^3.25.5",
"cross-env": "^7.0.3",
"css-loader": "^6.7.1",
"cssnano": "^5.1.13",
"easygettext": "^2.17.0",
"eslint": "^8.25.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-standard": "^17.0.0",
"eslint-formatter-pretty": "^4.1.0",
"eslint-plugin-html": "^7.1.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier-vue": "^4.2.0",
"eslint-plugin-promise": "^6.1.0",
"eslint-plugin-vue": "^9.6.0",
"eslint-webpack-plugin": "^3.2.0",
"eventsource-polyfill": "^0.9.6",
"file-loader": "^6.2.0",
"file-saver": "^2.0.5",
"hls.js": "^1.2.4",
"i": "^0.3.7",
"karma": "^6.4.1",
"karma-chrome-launcher": "^3.1.1",
"karma-coverage-istanbul-reporter": "^3.0.3",
"karma-htmlfile-reporter": "^0.3.8",
"karma-mocha": "^2.0.1",
"karma-verbose-reporter": "^0.0.8",
"karma-webpack": "^5.0.0",
"luxon": "^3.0.4",
"maplibre-gl": "^2.4.0",
"memoize-one": "^6.0.0",
"mini-css-extract-plugin": "^2.6.1",
"minimist": ">=1.2.5",
"mocha": "^10.1.0",
"node-storage-shim": "^2.0.1",
"photoswipe": "^4.1.3",
"postcss": "^8.4.18",
"postcss-import": "^15.0.0",
"postcss-loader": "^7.0.1",
"postcss-preset-env": "^7.8.2",
"postcss-reporter": "^7.0.5",
"postcss-url": "^10.1.3",
"prettier": "^2.7.1",
"pubsub-js": "^1.9.4",
"regenerator-runtime": "^0.13.10",
"resolve-url-loader": "^5.0.0",
"sass": "^1.55.0",
"sass-loader": "^13.1.0",
"server": "^1.0.37",
"sockette": "^2.0.6",
"style-loader": "^3.3.1",
"svg-url-loader": "^8.0.0",
"tar": "^6.1.11",
"url-loader": "^4.1.1",
"util": "^0.12.5",
"vue": "^2.6.14",
"vue-fullscreen": "^2.5.2",
"vue-gettext": "^2.1.12",
"vue-infinite-scroll": "^2.0.2",
"vue-loader": "^15.9.8",
"vue-loader-plugin": "^1.3.0",
"vue-luxon": "^0.10.0",
"vue-router": "^3.5.2",
"vue-style-loader": "^4.1.3",
"vue-template-compiler": "^2.7.10",
"vue2-filters": "^0.14.0",
"vuetify": "^1.5.24",
"webpack": "^5.74.0",
"webpack-bundle-analyzer": "^4.6.1",
"webpack-cli": "^4.10.0",
"webpack-hot-middleware": "^2.25.2",
"webpack-manifest-plugin": "^5.0.0",
"webpack-md5-hash": "^0.0.6",
"webpack-merge": "^5.8.0"
},
"engines": {
"node": ">= 16.0.0",
"npm": ">= 8.0.0",
"yarn": "please use npm"
},
"browserslist": ">0.25% and last 2 years"
}

View file

@ -4730,6 +4730,8 @@ with pkgs;
photon = callPackage ../tools/networking/photon { };
photoprism = callPackage ../servers/photoprism { };
piglit = callPackage ../tools/graphics/piglit { };
pika = callPackage ../applications/graphics/pika { };