|
| 1 | +{ |
| 2 | + lib, |
| 3 | + stdenv, |
| 4 | + fetchzip, |
| 5 | + fetchurl, |
| 6 | + makeDesktopItem, |
| 7 | + |
| 8 | + copyDesktopItems, |
| 9 | + makeWrapper, |
| 10 | + wine, |
| 11 | + winetricks, |
| 12 | +}: |
| 13 | + |
| 14 | +stdenv.mkDerivation rec { |
| 15 | + pname = "vtfedit"; |
| 16 | + version = "1.3.3"; |
| 17 | + |
| 18 | + src = fetchzip { |
| 19 | + url = "https://nemstools.github.io/files/vtfedit${lib.replaceStrings [ "." ] [ "" ] version}.zip"; |
| 20 | + hash = "sha256-6a8YuxgYm7FB+2pFcZAMtE1db4hqpEk0z5gv2wHl9bI="; |
| 21 | + stripRoot = false; |
| 22 | + }; |
| 23 | + |
| 24 | + icon = fetchurl { |
| 25 | + url = "https://web.archive.org/web/20230906220249im_/https://valvedev.info/tools/vtfedit/thumb.png"; |
| 26 | + hash = "sha256-Jpqo/s1wO2U5Z1DSZvADTfdH+8ycr0KF6otQbAE+jts="; |
| 27 | + }; |
| 28 | + |
| 29 | + nativeBuildInputs = [ |
| 30 | + copyDesktopItems |
| 31 | + makeWrapper |
| 32 | + ]; |
| 33 | + |
| 34 | + nativeRuntimeInputs = lib.makeBinPath [ |
| 35 | + wine |
| 36 | + winetricks |
| 37 | + ]; |
| 38 | + |
| 39 | + installPhase = '' |
| 40 | + runHook preInstall |
| 41 | +
|
| 42 | + mkdir -p $out/bin |
| 43 | + mkdir -p $out/share/icons/hicolor/256x256/apps |
| 44 | + mkdir -p $out/share/lib |
| 45 | + mkdir -p $out/share/mime/packages |
| 46 | +
|
| 47 | + substitute ${./vtfedit.bash} $out/bin/vtfedit \ |
| 48 | + --replace-fail "@out@" "${placeholder "out"}" \ |
| 49 | + --replace-fail "@path@" "${nativeRuntimeInputs}" |
| 50 | + chmod +x $out/bin/vtfedit |
| 51 | +
|
| 52 | + cp ${icon} $out/share/icons/hicolor/256x256/apps/vtfedit.png |
| 53 | + cp -r ${if wine.meta.mainProgram == "wine64" then "x64" else "x86"}/* $out/share/lib |
| 54 | + cp ${./mimetype.xml} $out/share/mime/packages/vtfedit.xml |
| 55 | +
|
| 56 | + runHook postInstall |
| 57 | + ''; |
| 58 | + |
| 59 | + desktopItems = [ |
| 60 | + (makeDesktopItem { |
| 61 | + name = pname; |
| 62 | + desktopName = "VTFEdit"; |
| 63 | + exec = "vtfedit %f"; |
| 64 | + icon = "vtfedit"; |
| 65 | + terminal = false; |
| 66 | + categories = [ "Graphics" ]; |
| 67 | + comment = meta.description; |
| 68 | + mimeTypes = [ "application/x-vtfedit" ]; |
| 69 | + }) |
| 70 | + ]; |
| 71 | + |
| 72 | + meta = { |
| 73 | + description = "VTF file viewer/editor"; |
| 74 | + homepage = "https://nemstools.github.io/pages/VTFLib.html"; |
| 75 | + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; |
| 76 | + license = lib.licenses.lgpl21Plus; |
| 77 | + inherit (wine.meta) platforms; |
| 78 | + maintainers = with lib.maintainers; [ paveloom ]; |
| 79 | + }; |
| 80 | +} |
0 commit comments