photoprism: 250321-57590c48b -> 250426-27ec7a128 (#407100)
This commit is contained in:
@@ -33,13 +33,31 @@ in
|
||||
enable = lib.mkEnableOption "Photoprism web server";
|
||||
|
||||
passwordFile = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.path;
|
||||
type = lib.types.nullOr (
|
||||
lib.types.pathWith {
|
||||
inStore = false;
|
||||
absolute = true;
|
||||
}
|
||||
);
|
||||
default = null;
|
||||
description = ''
|
||||
Admin password file.
|
||||
'';
|
||||
};
|
||||
|
||||
databasePasswordFile = lib.mkOption {
|
||||
type = lib.types.nullOr (
|
||||
lib.types.pathWith {
|
||||
inStore = false;
|
||||
absolute = true;
|
||||
}
|
||||
);
|
||||
default = null;
|
||||
description = ''
|
||||
Database password file.
|
||||
'';
|
||||
};
|
||||
|
||||
address = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "localhost";
|
||||
@@ -114,9 +132,12 @@ in
|
||||
cfg.storagePath
|
||||
];
|
||||
|
||||
LoadCredential = lib.optionalString (
|
||||
cfg.passwordFile != null
|
||||
) "PHOTOPRISM_ADMIN_PASSWORD:${cfg.passwordFile}";
|
||||
LoadCredential = [
|
||||
(lib.optionalString (cfg.passwordFile != null) "PHOTOPRISM_ADMIN_PASSWORD_FILE=${cfg.passwordFile}")
|
||||
(lib.optionalString (
|
||||
cfg.databasePasswordFile != null
|
||||
) "PHOTOPRISM_DATABASE_PASSWORD=${cfg.databasePasswordFile}")
|
||||
];
|
||||
|
||||
LockPersonality = true;
|
||||
PrivateDevices = true;
|
||||
@@ -146,19 +167,23 @@ in
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
environment = env;
|
||||
|
||||
# reminder: easier password configuration will come in https://github.com/photoprism/photoprism/pull/2302
|
||||
preStart = ''
|
||||
ln -sf ${manage} photoprism-manage
|
||||
|
||||
${lib.optionalString (cfg.passwordFile != null) ''
|
||||
export PHOTOPRISM_ADMIN_PASSWORD=$(cat "$CREDENTIALS_DIRECTORY/PHOTOPRISM_ADMIN_PASSWORD")
|
||||
export PHOTOPRISM_ADMIN_PASSWORD_FILE=$CREDENTIALS_DIRECTORY/PHOTOPRISM_ADMIN_PASSWORD_FILE
|
||||
''}
|
||||
${lib.optionalString (cfg.databasePasswordFile != null) ''
|
||||
export PHOTOPRISM_DATABASE_PASSWORD=$(cat "$CREDENTIALS_DIRECTORY/PHOTOPRISM_DATABASE_PASSWORD")
|
||||
''}
|
||||
exec ${cfg.package}/bin/photoprism migrations run -f
|
||||
'';
|
||||
|
||||
script = ''
|
||||
${lib.optionalString (cfg.passwordFile != null) ''
|
||||
export PHOTOPRISM_ADMIN_PASSWORD=$(cat "$CREDENTIALS_DIRECTORY/PHOTOPRISM_ADMIN_PASSWORD")
|
||||
export PHOTOPRISM_ADMIN_PASSWORD_FILE=$CREDENTIALS_DIRECTORY/PHOTOPRISM_ADMIN_PASSWORD_FILE
|
||||
''}
|
||||
${lib.optionalString (cfg.databasePasswordFile != null) ''
|
||||
export PHOTOPRISM_DATABASE_PASSWORD=$(cat "$CREDENTIALS_DIRECTORY/PHOTOPRISM_DATABASE_PASSWORD")
|
||||
''}
|
||||
exec ${cfg.package}/bin/photoprism start
|
||||
'';
|
||||
|
||||
@@ -2,14 +2,26 @@
|
||||
lib,
|
||||
buildGoModule,
|
||||
coreutils,
|
||||
libtensorflow,
|
||||
python3,
|
||||
src,
|
||||
version,
|
||||
pkg-config,
|
||||
vips,
|
||||
symlinkJoin,
|
||||
}:
|
||||
|
||||
buildGoModule rec {
|
||||
let
|
||||
# we need to copy these, to add the symlinks, so the linker actually finds these libraries
|
||||
libtensorflow = symlinkJoin {
|
||||
name = "libtensorflow";
|
||||
paths = [ "${python3.pkgs.tensorflow-bin}/${python3.sitePackages}/tensorflow" ];
|
||||
postBuild = ''
|
||||
ln -s "$out/libtensorflow_cc.so.2" "$out/libtensorflow.so"
|
||||
ln -s "$out/libtensorflow_framework.so.2" "$out/libtensorflow_framework.so"
|
||||
'';
|
||||
};
|
||||
in
|
||||
buildGoModule {
|
||||
inherit src version;
|
||||
pname = "photoprism-backend";
|
||||
|
||||
@@ -30,18 +42,17 @@ buildGoModule rec {
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace internal/commands/passwd.go --replace '/bin/stty' "${coreutils}/bin/stty"
|
||||
substituteInPlace internal/commands/passwd.go --replace-fail '/bin/stty' "${coreutils}/bin/stty"
|
||||
'';
|
||||
|
||||
vendorHash = "sha256-eHdnTpcVBSvGR9ZiK6A32jfjik8VClDTkv92bD8EIgA=";
|
||||
vendorHash = "sha256-8uy0uLhGOyedqi3AvMsEdDQnFvGgeeZcL4tFgI6bzU8=";
|
||||
|
||||
subPackages = [ "cmd/photoprism" ];
|
||||
|
||||
# https://github.com/mattn/go-sqlite3/issues/822
|
||||
CGO_CFLAGS = "-Wno-return-local-addr";
|
||||
CGO_CFLAGS = "-Wno-return-local-addr -I${libtensorflow}/include";
|
||||
|
||||
# https://github.com/tensorflow/tensorflow/issues/43847
|
||||
CGO_LDFLAGS = "-fuse-ld=gold";
|
||||
CGO_LDFLAGS = "-L${libtensorflow} -ltensorflow_framework";
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://photoprism.app";
|
||||
|
||||
@@ -13,7 +13,7 @@ buildNpmPackage {
|
||||
cd frontend
|
||||
'';
|
||||
|
||||
npmDepsHash = "sha256-3cytU/QaPSsGu/984AEh3YsdV4H5cjf/br3NSc5Zd1M=";
|
||||
npmDepsHash = "sha256-rfZ6VE3JRR8MrB61DqueXWNoOjDE+GJnyrNujGyc8wc=";
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
{
|
||||
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
|
||||
];
|
||||
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 ];
|
||||
};
|
||||
}
|
||||
@@ -17,18 +17,17 @@
|
||||
}:
|
||||
|
||||
let
|
||||
version = "250321-57590c48b";
|
||||
version = "250426-27ec7a128";
|
||||
pname = "photoprism";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "photoprism";
|
||||
repo = "photoprism";
|
||||
rev = version;
|
||||
hash = "sha256-tJA1Q8kcX4UYDCV+rmHyd5gfEU8WkoaqNfx1/0Iy3l8=";
|
||||
hash = "sha256-wsSWCTFfKQ+8aE8GKvXpA49LbBLMTE1lsJMYFLvquBM=";
|
||||
};
|
||||
|
||||
libtensorflow = callPackage ./libtensorflow.nix { };
|
||||
backend = callPackage ./backend.nix { inherit libtensorflow src version; };
|
||||
backend = callPackage ./backend.nix { inherit src version; };
|
||||
frontend = callPackage ./frontend.nix { inherit src version; };
|
||||
|
||||
fetchModel =
|
||||
@@ -99,7 +98,6 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
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";
|
||||
|
||||
Reference in New Issue
Block a user