Unverified Commit da26db7b authored by Tom van Dijk's avatar Tom van Dijk
Browse files

vintagestory: factor out `makeWrapperArgs`

parent 6a2e95c7
Loading
Loading
Loading
Loading
+55 −47
Original line number Diff line number Diff line
@@ -39,34 +39,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";
@@ -99,22 +79,27 @@ stdenv.mkDerivation (finalAttrs: {
    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,7 +108,30 @@ stdenv.mkDerivation (finalAttrs: {
     done
  '';

  passthru.updateScript = ./update.sh;
  passthru = {
    updateScript = ./update.sh;
    runtimeLibs = [
      gtk2
      sqlite
      openal
      cairo
      libGLU
      SDL2
      freealut
      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";