depot/third_party/nixpkgs/pkgs/applications/graphics/hydrus/default.nix
Default email 5e7c2d6cef Project import generated by Copybara.
GitOrigin-RevId: f99e5f03cc0aa231ab5950a15ed02afec45ed51a
2023-10-09 21:29:22 +02:00

141 lines
3.4 KiB
Nix

{ lib
, fetchFromGitHub
, wrapQtAppsHook
, miniupnpc
, ffmpeg
, enableSwftools ? false
, swftools
, python3Packages
, qtbase
, qtcharts
}:
python3Packages.buildPythonPackage rec {
pname = "hydrus";
version = "544";
format = "other";
src = fetchFromGitHub {
owner = "hydrusnetwork";
repo = "hydrus";
rev = "refs/tags/v${version}";
hash = "sha256-e3VvkdJAQx5heKDJ1Ms6XpXrXWdzv48f8yu0DHfPy1A=";
};
patches = [
# Nixpkgs specific, can be removed if upstream makes a more reasonable check
./0001-inform-nixpkgs.patch
];
nativeBuildInputs = [
wrapQtAppsHook
python3Packages.mkdocs-material
];
buildInputs = [
qtbase
qtcharts
];
propagatedBuildInputs = with python3Packages; [
beautifulsoup4
cbor2
chardet
cloudscraper
dateparser
html5lib
lxml
lz4
numpy
opencv4
pillow
pillow-heif
psutil
psd-tools
pympler
pyopenssl
pyqt6
pyqt6-charts
pysocks
python-dateutil
python3Packages.mpv
pyyaml
qtpy
requests
send2trash
service-identity
twisted
];
nativeCheckInputs = with python3Packages; [
nose
mock
httmock
];
# most tests are failing, presumably because we are not using test.py
checkPhase = ''
nosetests $src/hydrus/test \
-e TestClientAPI \
-e TestClientConstants \
-e TestClientDaemons \
-e TestClientData \
-e TestClientDB \
-e TestClientDBDuplicates \
-e TestClientDBTags \
-e TestClientImageHandling \
-e TestClientImportOptions \
-e TestClientListBoxes \
-e TestClientMigration \
-e TestClientNetworking \
-e TestClientTags \
-e TestClientThreading \
-e TestDialogs \
-e TestFunctions \
-e TestHydrusNetwork \
-e TestHydrusNATPunch \
-e TestHydrusSerialisable \
-e TestHydrusServer \
-e TestHydrusSessions \
-e TestServer \
-e TestClientMetadataMigration \
-e TestClientFileStorage \
'';
outputs = [ "out" "doc" ];
installPhase = ''
# Move the hydrus module and related directories
mkdir -p $out/${python3Packages.python.sitePackages}
mv {hydrus,static} $out/${python3Packages.python.sitePackages}
# Fix random files being marked with execute permissions
chmod -x $out/${python3Packages.python.sitePackages}/static/*.{png,svg,ico}
# Build docs
mkdocs build -d help
mv help $out/doc/
# install the hydrus binaries
mkdir -p $out/bin
install -m0755 hydrus_server.py $out/bin/hydrus-server
install -m0755 hydrus_client.py $out/bin/hydrus-client
'' + lib.optionalString enableSwftools ''
mkdir -p $out/${python3Packages.python.sitePackages}/bin
# swfrender seems to have to be called sfwrender_linux
# not sure if it can be loaded through PATH, but this is simpler
# $out/python3Packages.python.sitePackages/bin is correct NOT .../hydrus/bin
ln -s ${swftools}/bin/swfrender $out/${python3Packages.python.sitePackages}/bin/swfrender_linux
'';
dontWrapQtApps = true;
preFixup = ''
makeWrapperArgs+=("''${qtWrapperArgs[@]}")
makeWrapperArgs+=(--prefix PATH : ${lib.makeBinPath [ ffmpeg miniupnpc ]})
'';
meta = with lib; {
description = "Danbooru-like image tagging and searching system for the desktop";
license = licenses.wtfpl;
homepage = "https://hydrusnetwork.github.io/hydrus/";
maintainers = with maintainers; [ dandellion evanjs ];
};
}