From da26db7be45ea9a205f708f97076d83ccd4853ed Mon Sep 17 00:00:00 2001 From: Tom van Dijk <18gatenmaker6@gmail.com> Date: Sat, 7 Jun 2025 18:56:27 +0200 Subject: [PATCH] vintagestory: factor out `makeWrapperArgs` Co-authored-by: ShamrockLee --- pkgs/by-name/vi/vintagestory/package.nix | 96 +++++++++++++----------- 1 file changed, 52 insertions(+), 44 deletions(-) diff --git a/pkgs/by-name/vi/vintagestory/package.nix b/pkgs/by-name/vi/vintagestory/package.nix index ce5ee91fcdbc..42a4bd89f292 100644 --- a/pkgs/by-name/vi/vintagestory/package.nix +++ b/pkgs/by-name/vi/vintagestory/package.nix @@ -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,31 +79,59 @@ stdenv.mkDerivation (finalAttrs: { runHook postInstall ''; - preFixup = - let - runtimeLibs' = lib.strings.makeLibraryPath finalAttrs.runtimeLibs; - in - '' - 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 \ - ''} \ - --add-flags $out/share/vintagestory/Vintagestory.dll + makeWrapperArgs = [ + "--set-default" + "mesa_glthread" + "true" + ] + ++ lib.optionals waylandSupport [ + "--set-default" + "OPENTK_4_USE_WAYLAND" + "1" + ]; - makeWrapper ${lib.meta.getExe dotnet-runtime_8} $out/bin/vintagestory-server \ - --prefix LD_LIBRARY_PATH : "${runtimeLibs'}" \ - --set-default mesa_glthread true \ - --add-flags $out/share/vintagestory/VintagestoryServer.dll + runtimeLibraryPath = lib.makeLibraryPath finalAttrs.passthru.runtimeLibs; + preFixup = '' + makeWrapperArgs+=(--prefix LD_LIBRARY_PATH : "$runtimeLibraryPath") - find "$out/share/vintagestory/assets/" -not -path "*/fonts/*" -regex ".*/.*[A-Z].*" | while read -r file; do - local filename="$(basename -- "$file")" - ln -sf "$filename" "''${file%/*}"/"''${filename,,}" - done - ''; + makeWrapper ${lib.meta.getExe dotnet-runtime_8} $out/bin/vintagestory \ + "''${makeWrapperArgs[@]}" \ + --add-flags $out/share/vintagestory/Vintagestory.dll - passthru.updateScript = ./update.sh; + 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 + local filename="$(basename -- "$file")" + ln -sf "$filename" "''${file%/*}"/"''${filename,,}" + done + ''; + + 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";