Unverified Commit 7b110a97 authored by Artturin's avatar Artturin Committed by GitHub
Browse files

vintagestory: modernize (#420002)

parents d63f32e4 cdfe9595
Loading
Loading
Loading
Loading
+57 −53
Original line number Diff line number Diff line
@@ -5,13 +5,9 @@
  makeWrapper,
  makeDesktopItem,
  copyDesktopItems,
  gtk2,
  sqlite,
  openal,
  versionCheckHook,
  cairo,
  libGLU,
  SDL2,
  freealut,
  libglvnd,
  pipewire,
  libpulseaudio,
@@ -39,34 +35,14 @@ stdenv.mkDerivation (finalAttrs: {
    hash = "sha256-LkiL/8W9MKpmJxtK+s5JvqhOza0BLap1SsaDvbLYR0c=";
  };

  __structuredAttrs = true;

  nativeBuildInputs = [
    makeWrapper
    copyDesktopItems
    imagemagick
  ];

  runtimeLibs = [
    gtk2
    sqlite
    openal
    cairo
    libGLU
    SDL2
    freealut
    libglvnd
    pipewire
    libpulseaudio
  ]
  ++ lib.optionals x11Support [
    libx11
    libxi
    libxcursor
  ]
  ++ lib.optionals waylandSupport [
    wayland
    libxkbcommon
  ];

  desktopItems = [
    (makeDesktopItem {
      name = "vintagestory";
@@ -96,25 +72,32 @@ stdenv.mkDerivation (finalAttrs: {
    magick $out/share/vintagestory/assets/gameicon.xpm $out/share/icons/hicolor/512x512/apps/vintagestory.png
    cp $out/share/vintagestory/assets/game/fonts/*.ttf $out/share/fonts/truetype

    rm -rvf $out/share/vintagestory/{install,run,server}.sh

    runHook postInstall
  '';

  preFixup =
    let
      runtimeLibs' = lib.strings.makeLibraryPath finalAttrs.runtimeLibs;
    in
    ''
  makeWrapperArgs = [
    "--set-default"
    "mesa_glthread"
    "true"
  ]
  ++ lib.optionals waylandSupport [
    "--set-default"
    "OPENTK_4_USE_WAYLAND"
    "1"
  ];

  runtimeLibraryPath = lib.makeLibraryPath finalAttrs.passthru.runtimeLibs;
  preFixup = ''
     makeWrapperArgs+=(--prefix LD_LIBRARY_PATH : "$runtimeLibraryPath")

     makeWrapper ${lib.meta.getExe dotnet-runtime_8} $out/bin/vintagestory \
        --prefix LD_LIBRARY_PATH : "${runtimeLibs'}" \
        --set-default mesa_glthread true \
        ${lib.strings.optionalString waylandSupport ''
          --set-default OPENTK_4_USE_WAYLAND 1 \
        ''} \
      "''${makeWrapperArgs[@]}" \
       --add-flags $out/share/vintagestory/Vintagestory.dll

      makeWrapper ${lib.meta.getExe dotnet-runtime_8} $out/bin/vintagestory-server \
        --prefix LD_LIBRARY_PATH : "${runtimeLibs'}" \
        --set-default mesa_glthread true \
    makeWrapper ${lib.getExe dotnet-runtime_8} $out/bin/vintagestory-server \
      "''${makeWrapperArgs[@]}" \
      --add-flags $out/share/vintagestory/VintagestoryServer.dll

     find "$out/share/vintagestory/assets/" -not -path "*/fonts/*" -regex ".*/.*[A-Z].*" | while read -r file; do
@@ -123,14 +106,35 @@ stdenv.mkDerivation (finalAttrs: {
     done
  '';

  passthru.updateScript = ./update.sh;
  doInstallCheck = true;
  installCheckInputs = [ versionCheckHook ];

  passthru = {
    updateScript = ./update.sh;
    runtimeLibs = [
      cairo
      libGLU
      libglvnd
      pipewire
      libpulseaudio
    ]
    ++ lib.optionals x11Support [
      libx11
      libxi
      libxcursor
    ]
    ++ lib.optionals waylandSupport [
      wayland
      libxkbcommon
    ];
  };

  meta = {
    description = "In-development indie sandbox game about innovation and exploration";
    homepage = "https://www.vintagestory.at/";
    license = lib.licenses.unfree;
    sourceProvenance = [ lib.sourceTypes.binaryBytecode ];
    platforms = lib.platforms.linux;
    platforms = [ "x86_64-linux" ];
    maintainers = with lib.maintainers; [
      artturin
      gigglesquid