1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
{ lib, stdenv, fetchFromGitHub, fetchzip, darktable, rawtherapee, ffmpeg_7, libheif, exiftool, imagemagick, makeWrapper, testers
, callPackage
, nixosTests
, librsvg }:
let
version = "240711-2197af848";
pname = "photoprism";
src = fetchFromGitHub {
owner = pname;
repo = pname;
rev = version;
hash = "sha256-ihDv5c5RUjDbFcAHJjzp/8qCwKfA+rlFXPziaYarzs8=";
};
libtensorflow = callPackage ./libtensorflow.nix { };
backend = callPackage ./backend.nix { inherit libtensorflow src version; };
frontend = callPackage ./frontend.nix { inherit src version; };
fetchModel = { name, hash }:
fetchzip {
inherit hash;
url = "https://dl.photoprism.org/tensorflow/${name}.zip";
stripRoot = false;
};
facenet = fetchModel {
name = "facenet";
hash = "sha256-aS5kkNhxOLSLTH/ipxg7NAa1w9X8iiG78jmloR1hpRo=";
};
nasnet = fetchModel {
name = "nasnet";
hash = "sha256-bF25jPmZLyeSWy/CGXZE/VE2UupEG2q9Jmr0+1rUYWE=";
};
nsfw = fetchModel {
name = "nsfw";
hash = "sha256-zy/HcmgaHOY7FfJUY6I/yjjsMPHR2Ote9ppwqemBlfg=";
};
assets_path = "$out/share/${pname}";
in
stdenv.mkDerivation (finalAttrs: {
inherit pname version;
nativeBuildInputs = [
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-dec \
--set PHOTOPRISM_RSVGCONVERT_BIN ${librsvg}/bin/rsvg-convert \
--set PHOTOPRISM_FFMPEG_BIN ${ffmpeg_7}/bin/ffmpeg \
--set PHOTOPRISM_EXIFTOOL_BIN ${exiftool}/bin/exiftool \
--set PHOTOPRISM_IMAGEMAGICK_BIN ${imagemagick}/bin/convert
# 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.version = testers.testVersion { package = finalAttrs.finalPackage; };
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 ];
mainProgram = "photoprism";
};
})
|