diff --git a/pkgs/by-name/vt/vtfedit/mimetype.xml b/pkgs/by-name/vt/vtfedit/mimetype.xml new file mode 100644 index 0000000000000..6abbedd57ef8f --- /dev/null +++ b/pkgs/by-name/vt/vtfedit/mimetype.xml @@ -0,0 +1,7 @@ + + + + Valve Texture Format + + + diff --git a/pkgs/by-name/vt/vtfedit/package.nix b/pkgs/by-name/vt/vtfedit/package.nix new file mode 100644 index 0000000000000..77ee821ad7e49 --- /dev/null +++ b/pkgs/by-name/vt/vtfedit/package.nix @@ -0,0 +1,80 @@ +{ + lib, + stdenv, + fetchzip, + fetchurl, + makeDesktopItem, + + copyDesktopItems, + makeWrapper, + wine, + winetricks, +}: + +stdenv.mkDerivation rec { + pname = "vtfedit"; + version = "1.3.3"; + + src = fetchzip { + url = "https://nemstools.github.io/files/vtfedit${lib.replaceStrings [ "." ] [ "" ] version}.zip"; + hash = "sha256-6a8YuxgYm7FB+2pFcZAMtE1db4hqpEk0z5gv2wHl9bI="; + stripRoot = false; + }; + + icon = fetchurl { + url = "https://web.archive.org/web/20230906220249im_/https://valvedev.info/tools/vtfedit/thumb.png"; + hash = "sha256-Jpqo/s1wO2U5Z1DSZvADTfdH+8ycr0KF6otQbAE+jts="; + }; + + nativeBuildInputs = [ + copyDesktopItems + makeWrapper + ]; + + nativeRuntimeInputs = lib.makeBinPath [ + wine + winetricks + ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + mkdir -p $out/share/icons/hicolor/256x256/apps + mkdir -p $out/share/lib + mkdir -p $out/share/mime/packages + + substitute ${./vtfedit.bash} $out/bin/vtfedit \ + --replace-fail "@out@" "${placeholder "out"}" \ + --replace-fail "@path@" "${nativeRuntimeInputs}" + chmod +x $out/bin/vtfedit + + cp ${icon} $out/share/icons/hicolor/256x256/apps/vtfedit.png + cp -r ${if wine.meta.mainProgram == "wine64" then "x64" else "x86"}/* $out/share/lib + cp ${./mimetype.xml} $out/share/mime/packages/vtfedit.xml + + runHook postInstall + ''; + + desktopItems = [ + (makeDesktopItem { + name = pname; + desktopName = "VTFEdit"; + exec = "vtfedit %f"; + icon = "vtfedit"; + terminal = false; + categories = [ "Graphics" ]; + comment = meta.description; + mimeTypes = [ "application/x-vtfedit" ]; + }) + ]; + + meta = { + description = "VTF file viewer/editor"; + homepage = "https://nemstools.github.io/pages/VTFLib.html"; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + license = lib.licenses.lgpl21Plus; + inherit (wine.meta) platforms; + maintainers = with lib.maintainers; [ paveloom ]; + }; +} diff --git a/pkgs/by-name/vt/vtfedit/vtfedit.bash b/pkgs/by-name/vt/vtfedit/vtfedit.bash new file mode 100755 index 0000000000000..4af4943928db0 --- /dev/null +++ b/pkgs/by-name/vt/vtfedit/vtfedit.bash @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -e + +OUT="@out@" +PATH="@path@:$PATH" + +PKGNAME="vtfedit" +PKGBIN="$OUT/share/lib/VTFEdit.exe" + +export WINEDEBUG="-all" +export WINEPREFIX="$HOME/.local/share/$PKGNAME/wine" + +if [[ ! -d "$WINEPREFIX" ]]; then + echo "Initialising the Wine prefix..." + WINEDLLOVERRIDES="mscoree=" winetricks -q winxp + echo "Installing DLLs..." + winetricks -q dlls dotnet20 vcrun2005 +fi + +wine "$PKGBIN" "$@" diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8be74f5c5488c..efaccf271c6b8 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -23317,6 +23317,10 @@ with pkgs; gtkVersion = "4"; }; + vtfedit = callPackage ../by-name/vt/vtfedit/package.nix { + wine = wineWowPackages.staging; + }; + vtk_9 = libsForQt5.callPackage ../development/libraries/vtk/9.x.nix { inherit (darwin) libobjc; inherit (darwin.apple_sdk.libs) xpc;