nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 171 lines 3.8 kB view raw
1{ 2 lib, 3 stdenv, 4 python3Packages, 5 fetchFromGitHub, 6 qt6, 7 copyDesktopItems, 8 makeDesktopItem, 9 writableTmpDirAsHomeHook, 10 swftools, 11 ffmpeg, 12 miniupnpc, 13 14 enableSwftools ? false, 15}: 16 17python3Packages.buildPythonApplication rec { 18 pname = "hydrus"; 19 version = "653"; 20 pyproject = false; 21 22 src = fetchFromGitHub { 23 owner = "hydrusnetwork"; 24 repo = "hydrus"; 25 tag = "v${version}"; 26 hash = "sha256-OH07OvN5EaEsjlUHUJMqproiVcN75yL9u7lnCjXSITo="; 27 }; 28 29 nativeBuildInputs = [ 30 qt6.wrapQtAppsHook 31 python3Packages.mkdocs-material 32 copyDesktopItems 33 ]; 34 35 buildInputs = [ 36 qt6.qtbase 37 qt6.qtcharts 38 ]; 39 40 desktopItems = [ 41 (makeDesktopItem { 42 name = "hydrus-client"; 43 exec = "hydrus-client"; 44 desktopName = "Hydrus Client"; 45 icon = "hydrus-client"; 46 comment = meta.description; 47 terminal = false; 48 type = "Application"; 49 categories = [ 50 "FileTools" 51 "Utility" 52 ]; 53 }) 54 ]; 55 56 dependencies = with python3Packages; [ 57 beautifulsoup4 58 cbor2 59 chardet 60 cloudscraper 61 dateparser 62 html5lib 63 lxml 64 lz4 65 numpy 66 opencv4 67 olefile 68 pillow 69 pillow-heif 70 psutil 71 psd-tools 72 pympler 73 pyopenssl 74 pyqt6 75 pyqt6-charts 76 pysocks 77 python-dateutil 78 python3Packages.mpv 79 pyyaml 80 qtpy 81 requests 82 show-in-file-manager 83 send2trash 84 service-identity 85 twisted 86 ]; 87 88 nativeCheckInputs = 89 (with python3Packages; [ 90 mock 91 httmock 92 ]) 93 ++ [ 94 writableTmpDirAsHomeHook 95 ]; 96 97 outputs = [ 98 "out" 99 "doc" 100 ]; 101 102 installPhase = '' 103 runHook preInstall 104 105 # Move the hydrus module and related directories 106 mkdir -p $out/${python3Packages.python.sitePackages} 107 mv {hydrus,static,db} $out/${python3Packages.python.sitePackages} 108 # Fix random files being marked with execute permissions 109 chmod -x $out/${python3Packages.python.sitePackages}/static/*.{png,svg,ico} 110 # Build docs 111 mkdocs build -d help 112 mkdir -p $doc/share/doc 113 mv help $doc/share/doc/hydrus 114 115 # install the hydrus binaries 116 mkdir -p $out/bin 117 install -m0755 hydrus_server.py $out/bin/hydrus-server 118 install -m0755 hydrus_client.py $out/bin/hydrus-client 119 install -m0755 hydrus_test.py $out/bin/hydrus-test 120 121 # desktop item 122 mkdir -p "$out/share/icons/hicolor/scalable/apps" 123 ln -s "$doc/share/doc/hydrus/assets/hydrus-white.svg" "$out/share/icons/hicolor/scalable/apps/hydrus-client.svg" 124 '' 125 + lib.optionalString enableSwftools '' 126 mkdir -p $out/${python3Packages.python.sitePackages}/bin 127 # swfrender seems to have to be called sfwrender_linux 128 # not sure if it can be loaded through PATH, but this is simpler 129 # $out/python3Packages.python.sitePackages/bin is correct NOT .../hydrus/bin 130 ln -s ${swftools}/bin/swfrender $out/${python3Packages.python.sitePackages}/bin/swfrender_linux 131 '' 132 + '' 133 runHook postInstall 134 ''; 135 136 checkPhase = '' 137 runHook preCheck 138 139 export QT_QPA_PLATFORM=offscreen 140 $out/bin/hydrus-test 141 142 runHook postCheck 143 ''; 144 145 # Tests crash even with __darwinAllowLocalNetworking enabled 146 # hydrus.core.HydrusExceptions.DataMissing: That service was not found! 147 doCheck = !stdenv.hostPlatform.isDarwin; 148 149 dontWrapQtApps = true; 150 preFixup = '' 151 makeWrapperArgs+=("''${qtWrapperArgs[@]}") 152 makeWrapperArgs+=(--prefix PATH : ${ 153 lib.makeBinPath [ 154 ffmpeg 155 miniupnpc 156 ] 157 }) 158 ''; 159 160 meta = { 161 description = "Danbooru-like image tagging and searching system for the desktop"; 162 license = lib.licenses.wtfpl; 163 homepage = "https://hydrusnetwork.github.io/hydrus/"; 164 changelog = "https://github.com/hydrusnetwork/hydrus/releases/tag/${src.tag}"; 165 maintainers = with lib.maintainers; [ 166 dandellion 167 evanjs 168 KunyaKud 169 ]; 170 }; 171}