chore(nix): sync with upstream Prism Launcher

This commit is contained in:
Evan Goode 2024-11-30 17:24:43 -05:00 committed by Luna
parent e0088f7811
commit 6ec444e0c4
3 changed files with 253 additions and 283 deletions

185
flake.nix
View File

@ -2,7 +2,7 @@
description = "Prism Launcher fork with support for alternative auth servers"; description = "Prism Launcher fork with support for alternative auth servers";
nixConfig = { nixConfig = {
extra-substituters = [ "https://unmojang.cachix.org" ]; extra-substituters = ["https://unmojang.cachix.org"];
extra-trusted-public-keys = [ extra-trusted-public-keys = [
"unmojang.cachix.org-1:OfHnbBNduZ6Smx9oNbLFbYyvOWSoxb2uPcnXPj4EDQY=" "unmojang.cachix.org-1:OfHnbBNduZ6Smx9oNbLFbYyvOWSoxb2uPcnXPj4EDQY="
]; ];
@ -19,18 +19,18 @@
nix-filter.url = "github:numtide/nix-filter"; nix-filter.url = "github:numtide/nix-filter";
/* /*
Inputs below this are optional and can be removed Inputs below this are optional and can be removed
``` ```
{ {
inputs.shatteredprism = { inputs.shatteredprism = {
url = "github:lunaislazier/ShatteredPrism"; url = "github:lunaislazier/ShatteredPrism";
inputs = { inputs = {
flake-compat.follows = ""; flake-compat.follows = "";
};
}; };
} };
``` }
```
*/ */
flake-compat = { flake-compat = {
@ -39,105 +39,90 @@
}; };
}; };
outputs = outputs = {
{ self,
self, nixpkgs,
nixpkgs, libnbtplusplus,
libnbtplusplus, nix-filter,
nix-filter, ...
... }: let
}: inherit (nixpkgs) lib;
let
inherit (nixpkgs) lib;
# While we only officially support aarch and x86_64 on Linux and MacOS, # While we only officially support aarch and x86_64 on Linux and MacOS,
# we expose a reasonable amount of other systems for users who want to # we expose a reasonable amount of other systems for users who want to
# build for most exotic platforms # build for most exotic platforms
systems = lib.systems.flakeExposed; systems = lib.systems.flakeExposed;
forAllSystems = lib.genAttrs systems; forAllSystems = lib.genAttrs systems;
nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system}); nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});
in in {
{ checks = forAllSystems (
checks = forAllSystems ( system: let
system: checks' = nixpkgsFor.${system}.callPackage ./nix/checks.nix {inherit self;};
let in
checks' = nixpkgsFor.${system}.callPackage ./nix/checks.nix { inherit self; };
in
lib.filterAttrs (_: lib.isDerivation) checks' lib.filterAttrs (_: lib.isDerivation) checks'
); );
devShells = forAllSystems ( devShells = forAllSystems (
system: system: let
let pkgs = nixpkgsFor.${system};
pkgs = nixpkgsFor.${system}; in {
in default = pkgs.mkShell {
{ inputsFrom = [self.packages.${system}.shatteredprism-unwrapped];
default = pkgs.mkShell { buildInputs = with pkgs; [
inputsFrom = [ self.packages.${system}.shatteredprism-unwrapped ]; ccache
buildInputs = with pkgs; [ ninja
ccache ];
ninja
];
};
}
);
formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
overlays.default =
final: prev:
let
version = builtins.substring 0 8 self.lastModifiedDate or "dirty";
in
{
shatteredprism-unwrapped = prev.callPackage ./nix/unwrapped.nix {
inherit
libnbtplusplus
nix-filter
self
version
;
};
shatteredprism = final.callPackage ./nix/wrapper.nix { };
}; };
}
);
packages = forAllSystems ( formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
system:
let
pkgs = nixpkgsFor.${system};
# Build a scope from our overlay overlays.default = final: prev: {
shatteredPackages = lib.makeScope pkgs.newScope (final: self.overlays.default final pkgs); shatteredprism-unwrapped = prev.callPackage ./nix/unwrapped.nix {
inherit
libnbtplusplus
nix-filter
self
;
};
# Grab our packages from it and set the default shatteredprism = final.callPackage ./nix/wrapper.nix {};
packages = { };
inherit (shatteredPackages) shatteredprism-unwrapped shatteredprism;
default = shatteredPackages.shatteredprism; packages = forAllSystems (
}; system: let
in pkgs = nixpkgsFor.${system};
# Build a scope from our overlay
shatteredPackages = lib.makeScope pkgs.newScope (final: self.overlays.default final pkgs);
# Grab our packages from it and set the default
packages = {
inherit (shatteredPackages) shatteredprism-unwrapped shatteredprism;
default = shatteredPackages.shatteredprism;
};
in
# Only output them if they're available on the current system # Only output them if they're available on the current system
lib.filterAttrs (_: lib.meta.availableOn pkgs.stdenv.hostPlatform) packages lib.filterAttrs (_: lib.meta.availableOn pkgs.stdenv.hostPlatform) packages
); );
# We put these under legacyPackages as they are meant for CI, not end user consumption # We put these under legacyPackages as they are meant for CI, not end user consumption
legacyPackages = forAllSystems ( legacyPackages = forAllSystems (
system: system: let
let shatteredPackages = self.packages.${system};
shatteredPackages = self.packages.${system}; legacyPackages = self.legacyPackages.${system};
legacyPackages = self.legacyPackages.${system}; in {
in shatteredprism-debug = shatteredPackages.shatteredprism.override {
{ shatteredprism-unwrapped = legacyPackages.shatteredprism-unwrapped-debug;
shatteredprism-debug = shatteredPackages.shatteredprism.override { };
shatteredprism-unwrapped = legacyPackages.shatteredprism-unwrapped-debug;
};
shatteredprism-unwrapped-debug = shatteredPackages.shatteredprism-unwrapped.overrideAttrs { shatteredprism-unwrapped-debug = shatteredPackages.shatteredprism-unwrapped.overrideAttrs {
cmakeBuildType = "Debug"; cmakeBuildType = "Debug";
dontStrip = true; dontStrip = true;
}; };
} }
); );
}; };
} }

View File

@ -3,12 +3,13 @@
stdenv, stdenv,
cmake, cmake,
cmark, cmark,
darwin, apple-sdk_11,
extra-cmake-modules, extra-cmake-modules,
gamemode, gamemode,
ghc_filesystem, ghc_filesystem,
jdk17, jdk17,
kdePackages, kdePackages,
libnbtplusplus,
ninja, ninja,
nix-filter, nix-filter,
self, self,
@ -16,92 +17,93 @@
tomlplusplus, tomlplusplus,
zlib, zlib,
msaClientID ? null, msaClientID ? null,
gamemodeSupport ? stdenv.isLinux, gamemodeSupport ? stdenv.hostPlatform.isLinux,
version,
libnbtplusplus,
}: }:
assert lib.assertMsg ( assert lib.assertMsg (
gamemodeSupport -> stdenv.isLinux gamemodeSupport -> stdenv.hostPlatform.isLinux
) "gamemodeSupport is only available on Linux."; ) "gamemodeSupport is only available on Linux.";
stdenv.mkDerivation { stdenv.mkDerivation {
pname = "shatteredprism-unwrapped"; pname = "shatteredprism-unwrapped";
inherit version; version = self.shortRev or self.dirtyShortRev or "unknown";
src = nix-filter.lib { src = nix-filter.lib {
root = self; root = self;
include = [ include = [
"buildconfig" "buildconfig"
"cmake" "cmake"
"launcher" "launcher"
"libraries" "libraries"
"program_info" "program_info"
"tests" "tests"
../COPYING.md ../COPYING.md
../CMakeLists.txt ../CMakeLists.txt
]; ];
}; };
postUnpack = '' postUnpack = ''
rm -rf source/libraries/libnbtplusplus rm -rf source/libraries/libnbtplusplus
ln -s ${libnbtplusplus} source/libraries/libnbtplusplus ln -s ${libnbtplusplus} source/libraries/libnbtplusplus
'';
nativeBuildInputs = [
cmake
ninja
extra-cmake-modules
jdk17
stripJavaArchivesHook
];
buildInputs =
[
cmark
ghc_filesystem
kdePackages.qtbase
kdePackages.qtnetworkauth
kdePackages.quazip
tomlplusplus
zlib
]
++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ]
++ lib.optional gamemodeSupport gamemode;
hardeningEnable = lib.optionals stdenv.isLinux [ "pie" ];
cmakeFlags =
[ (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 [
# we wrap our binary manually
(lib.cmakeFeature "INSTALL_BUNDLE" "nodeps")
# disable built-in updater
(lib.cmakeFeature "MACOSX_SPARKLE_UPDATE_FEED_URL" "''")
(lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/Applications/")
];
doCheck = true;
dontWrapQtApps = true;
meta = {
description = "Prism Launcher fork with support for alternative auth servers";
longDescription = ''
Allows you to have multiple, separate instances of Minecraft (each with
their own mods, texture packs, saves, etc) and helps you manage them and
their associated options with a simple interface.
''; '';
homepage = "https://github.com/lunaislazier/ShatteredPrism";
license = lib.licenses.gpl3Only; nativeBuildInputs = [
maintainers = with lib.maintainers; [ cmake
lunaislazier ninja
extra-cmake-modules
jdk17
stripJavaArchivesHook
]; ];
mainProgram = "shatteredprism";
platforms = lib.platforms.linux ++ lib.platforms.darwin; buildInputs =
}; [
} cmark
ghc_filesystem
kdePackages.qtbase
kdePackages.qtnetworkauth
kdePackages.quazip
tomlplusplus
zlib
]
++ lib.optionals stdenv.hostPlatform.isDarwin [apple-sdk_11]
++ lib.optional gamemodeSupport gamemode;
hardeningEnable = lib.optionals stdenv.hostPlatform.isLinux ["pie"];
cmakeFlags =
[
# 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.hostPlatform.isDarwin [
# we wrap our binary manually
(lib.cmakeFeature "INSTALL_BUNDLE" "nodeps")
# disable built-in updater
(lib.cmakeFeature "MACOSX_SPARKLE_UPDATE_FEED_URL" "''")
(lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/Applications/")
];
doCheck = true;
dontWrapQtApps = true;
meta = {
description = "Prism Launcher fork with support for alternative auth servers";
longDescription = ''
Allows you to have multiple, separate instances of Minecraft (each with
their own mods, texture packs, saves, etc) and helps you manage them and
their associated options with a simple interface.
'';
homepage = "https://github.com/lunaislazier/ShatteredPrism";
license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [
lunaislazier
];
mainProgram = "shatteredprism";
platforms = lib.platforms.linux ++ lib.platforms.darwin;
};
}

View File

@ -1,147 +1,130 @@
{ {
lib,
stdenv,
symlinkJoin,
shatteredprism-unwrapped,
addDriverRunpath, addDriverRunpath,
alsa-lib,
flite, flite,
gamemode, gamemode,
glfw, glfw3-minecraft,
glfw-wayland-minecraft,
glxinfo,
jdk8,
jdk17, jdk17,
jdk21, jdk21,
jdk8,
kdePackages, kdePackages,
lib,
libGL, libGL,
libX11,
libXcursor,
libXext,
libXrandr,
libXxf86vm,
libjack2,
libpulseaudio, libpulseaudio,
libusb1, libusb1,
makeWrapper, mesa-demos,
openal, openal,
pciutils, pciutils,
pipewire,
shatteredprism-unwrapped,
stdenv,
symlinkJoin,
udev, udev,
vulkan-loader, vulkan-loader,
xorg, xrandr,
additionalLibs ? [ ], additionalLibs ? [],
additionalPrograms ? [ ], additionalPrograms ? [],
controllerSupport ? stdenv.isLinux, controllerSupport ? stdenv.hostPlatform.isLinux,
gamemodeSupport ? stdenv.isLinux, gamemodeSupport ? stdenv.hostPlatform.isLinux,
jdks ? [ jdks ? [
jdk21 jdk21
jdk17 jdk17
jdk8 jdk8
], ],
msaClientID ? null, msaClientID ? null,
textToSpeechSupport ? stdenv.isLinux, textToSpeechSupport ? stdenv.hostPlatform.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,
}: }:
assert lib.assertMsg ( assert lib.assertMsg (
controllerSupport -> stdenv.isLinux controllerSupport -> stdenv.hostPlatform.isLinux
) "controllerSupport only has an effect on Linux."; ) "controllerSupport only has an effect on Linux.";
assert lib.assertMsg ( assert lib.assertMsg (
textToSpeechSupport -> stdenv.isLinux textToSpeechSupport -> stdenv.hostPlatform.isLinux
) "textToSpeechSupport only has an effect on Linux."; ) "textToSpeechSupport only has an effect on Linux."; let
assert lib.assertMsg ( shatteredprism' = shatteredprism-unwrapped.override {inherit msaClientID gamemodeSupport;};
withWaylandGLFW -> stdenv.isLinux
) "withWaylandGLFW is only available on Linux.";
let
shatteredprism' = shatteredprism-unwrapped.override { inherit msaClientID gamemodeSupport; };
in in
symlinkJoin { symlinkJoin {
name = "shatteredprism-${shatteredprism'.version}"; name = "shatteredprism-${shatteredprism'.version}";
paths = [ shatteredprism' ]; paths = [shatteredprism'];
nativeBuildInputs = nativeBuildInputs = [kdePackages.wrapQtAppsHook];
[
kdePackages.wrapQtAppsHook
]
# purposefully using a shell wrapper here for variable expansion
# see https://github.com/NixOS/nixpkgs/issues/172583
++ lib.optional withWaylandGLFW makeWrapper;
buildInputs = buildInputs =
[ [
kdePackages.qtbase kdePackages.qtbase
kdePackages.qtsvg kdePackages.qtsvg
] ]
++ lib.optional ( ++ lib.optional (
lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.isLinux lib.versionAtLeast kdePackages.qtbase.version "6" && stdenv.hostPlatform.isLinux
) kdePackages.qtwayland; )
kdePackages.qtwayland;
env = { postBuild = ''
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 wrapQtAppsHook
''; '';
qtWrapperArgs = qtWrapperArgs = let
let
runtimeLibs = runtimeLibs =
[ [
# lwjgl (lib.getLib stdenv.cc.cc)
glfw ## native versions
libpulseaudio glfw3-minecraft
libGL
openal openal
stdenv.cc.cc.lib
vulkan-loader # VulkanMod's lwjgl ## openal
alsa-lib
libjack2
libpulseaudio
pipewire
## glfw
libGL
libX11
libXcursor
libXext
libXrandr
libXxf86vm
udev # oshi udev # oshi
xorg.libX11 vulkan-loader # VulkanMod's lwjgl
xorg.libXext
xorg.libXcursor
xorg.libXrandr
xorg.libXxf86vm
] ]
++ lib.optional textToSpeechSupport flite ++ lib.optional textToSpeechSupport flite
++ lib.optional gamemodeSupport gamemode.lib ++ lib.optional gamemodeSupport gamemode.lib
++ lib.optional controllerSupport libusb1 ++ lib.optional controllerSupport libusb1
++ additionalLibs; ++ additionalLibs;
runtimePrograms = [ runtimePrograms =
glxinfo [
pciutils # need lspci mesa-demos
xorg.xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128 pciutils # need lspci
] ++ additionalPrograms; xrandr # needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
]
++ additionalPrograms;
in in
[ ["--prefix SHATTEREDPRISM_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}"]
"--prefix SHATTEREDPRISM_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}" ++ lib.optionals stdenv.hostPlatform.isLinux [
] "--set LD_LIBRARY_PATH ${addDriverRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}"
++ lib.optionals stdenv.isLinux [ "--prefix PATH : ${lib.makeBinPath runtimePrograms}"
"--set LD_LIBRARY_PATH ${addDriverRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}" ];
"--prefix PATH : ${lib.makeBinPath runtimePrograms}"
];
meta = { meta = {
inherit (shatteredprism'.meta) inherit
description (shatteredprism'.meta)
longDescription description
homepage longDescription
changelog homepage
license changelog
maintainers license
mainProgram maintainers
platforms mainProgram
; platforms
}; ;
} };
}