Revert "Parity with Upstream towards Nix"

This reverts commit 4de9053c05.
This commit is contained in:
Luna 2025-01-11 14:19:43 -06:00
parent 2129244378
commit 32b45d0fd7
4 changed files with 107 additions and 72 deletions

View File

@ -85,12 +85,18 @@
formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
overlays.default = final: prev: {
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
;
};

View File

@ -1,5 +1,11 @@
# Shattered Prism Nix Packaging
## Installing a stable release (nixpkgs)
Shattered Prism is packaged in [nixpkgs](https://github.com/NixOS/nixpkgs/) since 22.11.
See [Package variants](#package-variants) for a list of available packages.
## Installing a development release (flake)
We use [cachix](https://cachix.org/) to cache our development and release builds.
@ -199,7 +205,7 @@ nix-env -iA shatteredprism.shatteredprism
## Package variants
This repository offers the following packages:
Both Nixpkgs and this repository offer the following packages:
- `shatteredprism` - The preferred build, wrapped with everything necessary to run the launcher and Minecraft
- `shatteredprism-unwrapped` - A minimal build that allows for advanced customization of the launcher's runtime environment

View File

@ -3,13 +3,12 @@
stdenv,
cmake,
cmark,
apple-sdk_11,
darwin,
extra-cmake-modules,
gamemode,
ghc_filesystem,
jdk17,
kdePackages,
libnbtplusplus,
ninja,
nix-filter,
self,
@ -18,14 +17,16 @@
zlib,
msaClientID ? null,
gamemodeSupport ? stdenv.hostPlatform.isLinux,
gamemodeSupport ? stdenv.isLinux,
version,
libnbtplusplus,
}:
assert lib.assertMsg (
gamemodeSupport -> stdenv.hostPlatform.isLinux
gamemodeSupport -> stdenv.isLinux
) "gamemodeSupport is only available on Linux.";
stdenv.mkDerivation {
pname = "shatteredprism-unwrapped";
version = self.shortRev or self.dirtyShortRev or "unknown";
inherit version;
src = nix-filter.lib {
root = self;
@ -64,23 +65,20 @@ stdenv.mkDerivation {
tomlplusplus
zlib
]
++ lib.optionals stdenv.hostPlatform.isDarwin [ apple-sdk_11 ]
++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ]
++ lib.optional gamemodeSupport gamemode;
hardeningEnable = lib.optionals stdenv.hostPlatform.isLinux [ "pie" ];
hardeningEnable = lib.optionals stdenv.isLinux [ "pie" ];
cmakeFlags =
[
# downstream branding
(lib.cmakeFeature "Launcher_BUILD_PLATFORM" "nixpkgs")
]
[ (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 [
++ lib.optionals stdenv.isDarwin [
# we wrap our binary manually
(lib.cmakeFeature "INSTALL_BUNDLE" "nodeps")
# disable built-in updater
@ -102,7 +100,7 @@ stdenv.mkDerivation {
homepage = "https://github.com/lunaislazier/ShatteredPrism";
license = lib.licenses.gpl3Only;
maintainers = with lib.maintainers; [
evan-goode
lunaislazier
];
mainProgram = "shatteredprism";
platforms = lib.platforms.linux ++ lib.platforms.darwin;

View File

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