nixos/package/photoview/default.nix

80 lines
1.6 KiB
Nix
Raw Normal View History

2025-01-13 11:52:09 +08:00
{
lib,
pkg-config,
libjpeg_turbo,
libheif,
lapack,
dlib,
blas,
ffmpeg,
exiftool,
darktable,
fetchFromGitHub,
buildGoModule,
buildNpmPackage,
runCommandLocal,
makeWrapper,
}:
buildGoModule rec {
2024-03-04 09:26:16 +08:00
pname = "photoview";
2024-07-21 10:54:14 +08:00
version = "2.4.0";
2024-03-04 09:26:16 +08:00
source = fetchFromGitHub {
name = "${pname}-src";
owner = pname;
repo = pname;
rev = "refs/tags/v${version}";
2024-07-21 10:54:14 +08:00
hash = "sha256-ZfvBdQlyqONsrviZGL22Kt+AiPaVWwdoREDUrHDYyIs=";
2024-03-04 09:26:16 +08:00
};
src = source + "/api";
2024-07-21 10:54:14 +08:00
vendorHash = "sha256-Tn4OxSV41s/4n2Q3teJRJNc39s6eKW4xE9wW/CIR5Fg=";
2024-03-04 09:26:16 +08:00
nativeBuildInputs = [
pkg-config
makeWrapper
];
buildInputs = [
libjpeg_turbo
libheif
lapack
dlib
blas
];
ui = buildNpmPackage {
pname = "${pname}-ui";
inherit version;
src = source + "/ui";
#REACT_APP_API_ENDPOINT = "";
REACT_APP_BUILD_VERSION = version;
2025-01-13 11:52:09 +08:00
REACT_APP_BUILD_DATE = builtins.readFile (runCommandLocal "date" { } "date -uI > $out");
REACT_APP_BUILD_COMMIT_SHA = "nix";
2024-07-21 10:54:14 +08:00
npmDepsHash = "sha256-wUbfq+7SuJUBxfy9TxHVda8A0g4mmYCbzJT64XBN2mI=";
2024-03-04 09:26:16 +08:00
};
postInstall = ''
mkdir -p "$out/lib/${pname}"
mv "$out/bin/api" "$out/bin/${pname}"
2024-03-04 09:26:16 +08:00
wrapProgram $out/bin/${pname} \
2025-01-13 11:52:09 +08:00
--prefix PATH ":" "${
lib.makeBinPath [
ffmpeg
exiftool
darktable
]
}" \
2024-03-04 09:26:16 +08:00
--set PHOTOVIEW_SERVE_UI 1 \
--set PHOTOVIEW_UI_PATH "$out/lib/${pname}/ui"
cp -r \
"${src}/data/" \
"$out/lib/${pname}/data/"
2024-03-04 09:26:16 +08:00
cp -r \
"${ui}/lib/node_modules/photoview-ui/dist" \
"$out/lib/${pname}/ui"
'';
}