From a5c554cf6ee32afa41c5a2af1ea8e8feb0087a49 Mon Sep 17 00:00:00 2001 From: seth Date: Fri, 25 Oct 2024 02:33:29 -0400 Subject: [PATCH 1/2] chore(nix): sync with nixpkgs Signed-off-by: seth --- nix/unwrapped.nix | 20 ++++---- nix/wrapper.nix | 115 ++++++++++++++++++++-------------------------- 2 files changed, 63 insertions(+), 72 deletions(-) diff --git a/nix/unwrapped.nix b/nix/unwrapped.nix index 7fc383ff34..237f36c1f6 100644 --- a/nix/unwrapped.nix +++ b/nix/unwrapped.nix @@ -9,20 +9,21 @@ ghc_filesystem, jdk17, kdePackages, + libnbtplusplus, ninja, nix-filter, self, stripJavaArchivesHook, tomlplusplus, + version, zlib, + msaClientID ? null, - gamemodeSupport ? stdenv.isLinux, - version, - libnbtplusplus, + gamemodeSupport ? stdenv.hostPlatform.isLinux, }: assert lib.assertMsg ( - gamemodeSupport -> stdenv.isLinux + gamemodeSupport -> stdenv.hostPlatform.isLinux ) "gamemodeSupport is only available on Linux."; stdenv.mkDerivation { @@ -66,20 +67,23 @@ stdenv.mkDerivation { tomlplusplus zlib ] - ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ] ++ lib.optional gamemodeSupport gamemode; - hardeningEnable = lib.optionals stdenv.isLinux [ "pie" ]; + hardeningEnable = lib.optionals stdenv.hostPlatform.isLinux [ "pie" ]; cmakeFlags = - [ (lib.cmakeFeature "Launcher_BUILD_PLATFORM" "nixpkgs") ] + [ + # downstream branding + (lib.cmakeFeature "Launcher_BUILD_PLATFORM" "nixpkgs") + ] ++ lib.optionals (msaClientID != null) [ (lib.cmakeFeature "Launcher_MSA_CLIENT_ID" (toString msaClientID)) ] ++ lib.optionals (lib.versionOlder kdePackages.qtbase.version "6") [ (lib.cmakeFeature "Launcher_QT_VERSION_MAJOR" "5") ] - ++ lib.optionals stdenv.isDarwin [ + ++ lib.optionals stdenv.hostPlatform.isDarwin [ # we wrap our binary manually (lib.cmakeFeature "INSTALL_BUNDLE" "nodeps") # disable built-in updater diff --git a/nix/wrapper.nix b/nix/wrapper.nix index 5632d483ba..ab9b7144b9 100644 --- a/nix/wrapper.nix +++ b/nix/wrapper.nix @@ -1,73 +1,65 @@ { - lib, - stdenv, - symlinkJoin, - prismlauncher-unwrapped, - addOpenGLRunpath, + addDriverRunpath, + alsa-lib, flite, gamemode, - glfw, - glfw-wayland-minecraft, - glxinfo, - jdk8, + glfw3-minecraft, jdk17, jdk21, + jdk8, kdePackages, + lib, libGL, + libX11, + libXcursor, + libXext, + libXrandr, + libXxf86vm, + libjack2, libpulseaudio, libusb1, - makeWrapper, + mesa-demos, openal, pciutils, + pipewire, + prismlauncher-unwrapped, + stdenv, + symlinkJoin, udev, vulkan-loader, - xorg, + xrandr, + additionalLibs ? [ ], additionalPrograms ? [ ], - controllerSupport ? stdenv.isLinux, - gamemodeSupport ? stdenv.isLinux, + controllerSupport ? stdenv.hostPlatform.isLinux, + gamemodeSupport ? stdenv.hostPlatform.isLinux, jdks ? [ jdk21 jdk17 jdk8 ], msaClientID ? null, - textToSpeechSupport ? stdenv.isLinux, - # Adds `glfw-wayland-minecraft` to `LD_LIBRARY_PATH` - # when launched on wayland, allowing for the game to be run natively. - # Make sure to enable "Use system installation of GLFW" in instance settings - # for this to take effect - # - # Warning: This build of glfw may be unstable, and the launcher - # itself can take slightly longer to start - withWaylandGLFW ? false, + textToSpeechSupport ? stdenv.hostPlatform.isLinux, }: assert lib.assertMsg ( - controllerSupport -> stdenv.isLinux + controllerSupport -> stdenv.hostPlatform.isLinux ) "controllerSupport only has an effect on Linux."; assert lib.assertMsg ( - textToSpeechSupport -> stdenv.isLinux + textToSpeechSupport -> stdenv.hostPlatform.isLinux ) "textToSpeechSupport only has an effect on Linux."; -assert lib.assertMsg ( - withWaylandGLFW -> stdenv.isLinux -) "withWaylandGLFW is only available on Linux."; - let prismlauncher' = prismlauncher-unwrapped.override { inherit msaClientID gamemodeSupport; }; in + symlinkJoin { name = "prismlauncher-${prismlauncher'.version}"; paths = [ prismlauncher' ]; - nativeBuildInputs = - [ kdePackages.wrapQtAppsHook ] - # purposefully using a shell wrapper here for variable expansion - # see https://github.com/NixOS/nixpkgs/issues/172583 - ++ lib.optional withWaylandGLFW makeWrapper; + nativeBuildInputs = [ kdePackages.wrapQtAppsHook ]; buildInputs = [ @@ -75,45 +67,39 @@ symlinkJoin { kdePackages.qtsvg ] ++ lib.optional ( - lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.isLinux + lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.hostPlatform.isLinux ) kdePackages.qtwayland; - env = { - waylandPreExec = lib.optionalString withWaylandGLFW '' - if [ -n "$WAYLAND_DISPLAY" ]; then - export LD_LIBRARY_PATH=${lib.getLib glfw-wayland-minecraft}/lib:"$LD_LIBRARY_PATH" - fi - ''; - }; - - postBuild = - lib.optionalString withWaylandGLFW '' - qtWrapperArgs+=(--run "$waylandPreExec") - '' - + '' - wrapQtAppsHook - ''; + postBuild = '' + wrapQtAppsHook + ''; qtWrapperArgs = let runtimeLibs = [ - # lwjgl - glfw - libpulseaudio - libGL - openal stdenv.cc.cc.lib + ## native versions + glfw3-minecraft + openal - vulkan-loader # VulkanMod's lwjgl + ## openal + alsa-lib + libjack2 + libpulseaudio + pipewire + + ## glfw + libGL + libX11 + libXcursor + libXext + libXrandr + libXxf86vm udev # oshi - xorg.libX11 - xorg.libXext - xorg.libXcursor - xorg.libXrandr - xorg.libXxf86vm + vulkan-loader # VulkanMod's lwjgl ] ++ lib.optional textToSpeechSupport flite ++ lib.optional gamemodeSupport gamemode.lib @@ -121,14 +107,15 @@ symlinkJoin { ++ additionalLibs; runtimePrograms = [ - glxinfo + mesa-demos pciutils # need lspci - xorg.xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128 + xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128 ] ++ additionalPrograms; + in [ "--prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}" ] - ++ lib.optionals stdenv.isLinux [ - "--set LD_LIBRARY_PATH ${addOpenGLRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}" + ++ lib.optionals stdenv.hostPlatform.isLinux [ + "--set LD_LIBRARY_PATH ${addDriverRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}" "--prefix PATH : ${lib.makeBinPath runtimePrograms}" ]; From 63b10738b2a1065d55077e729fcada6e7f64d10a Mon Sep 17 00:00:00 2001 From: seth Date: Fri, 25 Oct 2024 02:34:15 -0400 Subject: [PATCH 2/2] chore(nix): use `self` for version Signed-off-by: seth --- flake.nix | 26 ++++++++++---------------- nix/unwrapped.nix | 3 +-- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/flake.nix b/flake.nix index f4ca782ecb..54add656dd 100644 --- a/flake.nix +++ b/flake.nix @@ -85,24 +85,18 @@ formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style); - overlays.default = - final: prev: - let - version = builtins.substring 0 8 self.lastModifiedDate or "dirty"; - in - { - prismlauncher-unwrapped = prev.callPackage ./nix/unwrapped.nix { - inherit - libnbtplusplus - nix-filter - self - version - ; - }; - - prismlauncher = final.callPackage ./nix/wrapper.nix { }; + overlays.default = final: prev: { + prismlauncher-unwrapped = prev.callPackage ./nix/unwrapped.nix { + inherit + libnbtplusplus + nix-filter + self + ; }; + prismlauncher = final.callPackage ./nix/wrapper.nix { }; + }; + packages = forAllSystems ( system: let diff --git a/nix/unwrapped.nix b/nix/unwrapped.nix index 237f36c1f6..1b14886ef5 100644 --- a/nix/unwrapped.nix +++ b/nix/unwrapped.nix @@ -15,7 +15,6 @@ self, stripJavaArchivesHook, tomlplusplus, - version, zlib, msaClientID ? null, @@ -28,7 +27,7 @@ assert lib.assertMsg ( stdenv.mkDerivation { pname = "prismlauncher-unwrapped"; - inherit version; + version = self.shortRev or self.dirtyShortRev or "unknown"; src = nix-filter.lib { root = self;