2024-09-25 03:40:28 +01:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchzip, darktable, rawtherapee, ffmpeg, libheif, exiftool, imagemagick, makeWrapper, testers
|
2024-09-17 02:32:58 +01:00
|
|
|
, callPackage
|
2024-08-17 23:29:43 +01:00
|
|
|
, nixosTests
|
2024-07-31 17:52:05 +01:00
|
|
|
, librsvg }:
|
2022-11-02 18:41:07 +00:00
|
|
|
|
|
|
|
let
|
2024-07-31 17:52:05 +01:00
|
|
|
version = "240711-2197af848";
|
2022-11-02 18:41:07 +00:00
|
|
|
pname = "photoprism";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = pname;
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2024-07-31 17:52:05 +01:00
|
|
|
hash = "sha256-ihDv5c5RUjDbFcAHJjzp/8qCwKfA+rlFXPziaYarzs8=";
|
2022-11-02 18:41:07 +00:00
|
|
|
};
|
|
|
|
|
2024-09-17 02:32:58 +01:00
|
|
|
libtensorflow = callPackage ./libtensorflow.nix { };
|
|
|
|
backend = callPackage ./backend.nix { inherit libtensorflow src version; };
|
|
|
|
frontend = callPackage ./frontend.nix { inherit src version; };
|
2022-11-02 18:41:07 +00:00
|
|
|
|
2023-10-11 20:16:42 +01:00
|
|
|
fetchModel = { name, hash }:
|
2022-11-02 18:41:07 +00:00
|
|
|
fetchzip {
|
2023-10-11 20:16:42 +01:00
|
|
|
inherit hash;
|
2022-11-02 18:41:07 +00:00
|
|
|
url = "https://dl.photoprism.org/tensorflow/${name}.zip";
|
|
|
|
stripRoot = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
facenet = fetchModel {
|
|
|
|
name = "facenet";
|
2023-10-11 20:16:42 +01:00
|
|
|
hash = "sha256-aS5kkNhxOLSLTH/ipxg7NAa1w9X8iiG78jmloR1hpRo=";
|
2022-11-02 18:41:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nasnet = fetchModel {
|
|
|
|
name = "nasnet";
|
2023-10-11 20:16:42 +01:00
|
|
|
hash = "sha256-bF25jPmZLyeSWy/CGXZE/VE2UupEG2q9Jmr0+1rUYWE=";
|
2022-11-02 18:41:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nsfw = fetchModel {
|
|
|
|
name = "nsfw";
|
2023-10-11 20:16:42 +01:00
|
|
|
hash = "sha256-zy/HcmgaHOY7FfJUY6I/yjjsMPHR2Ote9ppwqemBlfg=";
|
2022-11-02 18:41:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
assets_path = "$out/share/${pname}";
|
|
|
|
in
|
2024-09-17 02:32:58 +01:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2022-11-02 18:41:07 +00:00
|
|
|
inherit pname version;
|
|
|
|
|
2022-12-08 22:26:13 +00:00
|
|
|
nativeBuildInputs = [
|
2022-11-02 18:41:07 +00:00
|
|
|
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 \
|
2024-09-25 05:27:00 +01:00
|
|
|
--set PHOTOPRISM_HEIFCONVERT_BIN ${libheif}/bin/heif-dec \
|
2024-07-31 17:52:05 +01:00
|
|
|
--set PHOTOPRISM_RSVGCONVERT_BIN ${librsvg}/bin/rsvg-convert \
|
2024-08-27 22:52:44 +01:00
|
|
|
--set PHOTOPRISM_FFMPEG_BIN ${ffmpeg}/bin/ffmpeg \
|
2023-05-06 16:16:05 +01:00
|
|
|
--set PHOTOPRISM_EXIFTOOL_BIN ${exiftool}/bin/exiftool \
|
|
|
|
--set PHOTOPRISM_IMAGEMAGICK_BIN ${imagemagick}/bin/convert
|
2022-11-02 18:41:07 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
'';
|
|
|
|
|
2024-09-17 02:32:58 +01:00
|
|
|
passthru.tests.version = testers.testVersion { package = finalAttrs.finalPackage; };
|
2024-08-17 23:29:43 +01:00
|
|
|
passthru.tests.photoprism = nixosTests.photoprism;
|
2022-11-02 18:41:07 +00:00
|
|
|
|
|
|
|
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 ];
|
2023-11-23 21:09:35 +00:00
|
|
|
mainProgram = "photoprism";
|
2022-11-02 18:41:07 +00:00
|
|
|
};
|
2024-09-17 02:32:58 +01:00
|
|
|
})
|