aboutsummaryrefslogtreecommitdiff
path: root/nix
diff options
context:
space:
mode:
Diffstat (limited to 'nix')
-rw-r--r--nix/default.nix32
-rw-r--r--nix/dev.nix43
-rw-r--r--nix/distribution.nix66
-rw-r--r--nix/package.nix65
-rw-r--r--nix/pkg/default.nix74
-rw-r--r--nix/pkg/wrapper.nix95
6 files changed, 237 insertions, 138 deletions
diff --git a/nix/default.nix b/nix/default.nix
deleted file mode 100644
index 47172927..00000000
--- a/nix/default.nix
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- inputs,
- self,
- ...
-}: {
- imports = [
- ./dev.nix
- ./distribution.nix
- ];
-
- _module.args = {
- # User-friendly version number.
- version = builtins.substring 0 8 self.lastModifiedDate;
- };
-
- perSystem = {system, ...}: {
- # Nixpkgs instantiated for supported systems with our overlay.
- _module.args.pkgs = import inputs.nixpkgs {
- inherit system;
- overlays = [self.overlays.default];
- };
- };
-
- # Supported systems.
- systems = [
- "x86_64-linux"
- "aarch64-linux"
- # Disabled due to our packages not supporting darwin yet.
- # "x86_64-darwin"
- # "aarch64-darwin"
- ];
-}
diff --git a/nix/dev.nix b/nix/dev.nix
index c39e1565..c476ed10 100644
--- a/nix/dev.nix
+++ b/nix/dev.nix
@@ -1,42 +1,33 @@
{
- inputs,
- self,
- ...
-}: {
perSystem = {
- system,
+ config,
+ lib,
pkgs,
...
}: {
- checks = {
- pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
- src = self;
- hooks = {
- markdownlint.enable = true;
+ pre-commit.settings = {
+ hooks = {
+ markdownlint.enable = true;
- alejandra.enable = true;
- deadnix.enable = true;
- nil.enable = true;
+ alejandra.enable = true;
+ deadnix.enable = true;
+ nil.enable = true;
- clang-format = {
- enable = true;
- types_or = ["c" "c++" "java" "json" "objective-c"];
- };
+ clang-format = {
+ enable = true;
+ types_or = ["c" "c++" "java" "json" "objective-c"];
};
};
+
+ tools.clang-tools = lib.mkForce pkgs.clang-tools_16;
};
devShells.default = pkgs.mkShell {
- inherit (self.checks.${system}.pre-commit-check) shellHook;
- packages = with pkgs; [
- nodePackages.markdownlint-cli
- alejandra
- deadnix
- clang-tools
- nil
- ];
+ shellHook = ''
+ ${config.pre-commit.installationScript}
+ '';
- inputsFrom = [self.packages.${system}.prismlauncher-unwrapped];
+ inputsFrom = [config.packages.prismlauncher-unwrapped];
buildInputs = with pkgs; [ccache ninja];
};
diff --git a/nix/distribution.nix b/nix/distribution.nix
index 0f2e26f3..ca9999dc 100644
--- a/nix/distribution.nix
+++ b/nix/distribution.nix
@@ -1,29 +1,65 @@
{
inputs,
self,
- version,
...
}: {
- perSystem = {pkgs, ...}: {
- packages = {
- inherit (pkgs) prismlauncher-qt5-unwrapped prismlauncher-qt5 prismlauncher-unwrapped prismlauncher;
- default = pkgs.prismlauncher;
+ perSystem = {
+ lib,
+ pkgs,
+ ...
+ }: {
+ packages = let
+ ourPackages = lib.fix (final: self.overlays.default final pkgs);
+ in {
+ inherit
+ (ourPackages)
+ prismlauncher-qt5-unwrapped
+ prismlauncher-qt5
+ prismlauncher-unwrapped
+ prismlauncher
+ ;
+ default = ourPackages.prismlauncher;
};
};
flake = {
overlays.default = final: prev: let
- # Helper function to build prism against different versions of Qt.
- mkPrism = qt:
- qt.callPackage ./package.nix {
- inherit (inputs) libnbtplusplus;
- inherit self version;
- };
+ version = builtins.substring 0 8 self.lastModifiedDate or "dirty";
+
+ filteredSelf = inputs.nix-filter.lib.filter {
+ root = ../.;
+ include = [
+ "buildconfig"
+ "cmake"
+ "launcher"
+ "libraries"
+ "program_info"
+ "tests"
+ ../COPYING.md
+ ../CMakeLists.txt
+ ];
+ };
+
+ # common args for prismlauncher evaluations
+ unwrappedArgs = {
+ self = filteredSelf;
+
+ inherit (inputs) libnbtplusplus;
+ inherit ((final.darwin or prev.darwin).apple_sdk.frameworks) Cocoa;
+ inherit version;
+ };
in {
- prismlauncher-qt5-unwrapped = mkPrism final.libsForQt5;
- prismlauncher-qt5 = prev.prismlauncher-qt5.override {prismlauncher-unwrapped = final.prismlauncher-qt5-unwrapped;};
- prismlauncher-unwrapped = mkPrism final.qt6Packages;
- prismlauncher = prev.prismlauncher.override {inherit (final) prismlauncher-unwrapped;};
+ prismlauncher-qt5-unwrapped = prev.libsForQt5.callPackage ./pkg unwrappedArgs;
+
+ prismlauncher-qt5 = prev.libsForQt5.callPackage ./pkg/wrapper.nix {
+ prismlauncher-unwrapped = final.prismlauncher-qt5-unwrapped;
+ };
+
+ prismlauncher-unwrapped = prev.qt6Packages.callPackage ./pkg unwrappedArgs;
+
+ prismlauncher = prev.qt6Packages.callPackage ./pkg/wrapper.nix {
+ inherit (final) prismlauncher-unwrapped;
+ };
};
};
}
diff --git a/nix/package.nix b/nix/package.nix
deleted file mode 100644
index edc266dc..00000000
--- a/nix/package.nix
+++ /dev/null
@@ -1,65 +0,0 @@
-{
- lib,
- stdenv,
- cmake,
- ninja,
- jdk17,
- zlib,
- qtbase,
- quazip,
- extra-cmake-modules,
- tomlplusplus,
- cmark,
- ghc_filesystem,
- gamemode,
- msaClientID ? null,
- gamemodeSupport ? true,
- self,
- version,
- libnbtplusplus,
-}:
-stdenv.mkDerivation rec {
- pname = "prismlauncher-unwrapped";
- inherit version;
-
- src = lib.cleanSource self;
-
- nativeBuildInputs = [extra-cmake-modules cmake jdk17 ninja];
- buildInputs =
- [
- qtbase
- zlib
- quazip
- ghc_filesystem
- tomlplusplus
- cmark
- ]
- ++ lib.optional gamemodeSupport gamemode;
-
- hardeningEnable = ["pie"];
-
- cmakeFlags =
- lib.optionals (msaClientID != null) ["-DLauncher_MSA_CLIENT_ID=${msaClientID}"]
- ++ lib.optionals (lib.versionOlder qtbase.version "6") ["-DLauncher_QT_VERSION_MAJOR=5"];
-
- postUnpack = ''
- rm -rf source/libraries/libnbtplusplus
- ln -s ${libnbtplusplus} source/libraries/libnbtplusplus
- '';
-
- dontWrapQtApps = true;
-
- meta = with lib; {
- homepage = "https://prismlauncher.org/";
- description = "A free, open source launcher for Minecraft";
- 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.
- '';
- platforms = platforms.linux;
- changelog = "https://github.com/PrismLauncher/PrismLauncher/releases/tag/${version}";
- license = licenses.gpl3Only;
- maintainers = with maintainers; [minion3665 Scrumplex];
- };
-}
diff --git a/nix/pkg/default.nix b/nix/pkg/default.nix
new file mode 100644
index 00000000..fd19a0b3
--- /dev/null
+++ b/nix/pkg/default.nix
@@ -0,0 +1,74 @@
+{
+ lib,
+ stdenv,
+ canonicalize-jars-hook,
+ cmake,
+ cmark,
+ Cocoa,
+ ninja,
+ jdk17,
+ zlib,
+ qtbase,
+ quazip,
+ extra-cmake-modules,
+ tomlplusplus,
+ ghc_filesystem,
+ gamemode,
+ msaClientID ? null,
+ gamemodeSupport ? stdenv.isLinux,
+ self,
+ version,
+ libnbtplusplus,
+}:
+assert lib.assertMsg (stdenv.isLinux || !gamemodeSupport) "gamemodeSupport is only available on Linux";
+ stdenv.mkDerivation rec {
+ pname = "prismlauncher-unwrapped";
+ inherit version;
+
+ src = lib.cleanSource self;
+
+ nativeBuildInputs = [extra-cmake-modules cmake jdk17 ninja canonicalize-jars-hook];
+ buildInputs =
+ [
+ qtbase
+ zlib
+ quazip
+ ghc_filesystem
+ tomlplusplus
+ cmark
+ ]
+ ++ lib.optional gamemodeSupport gamemode
+ ++ lib.optionals stdenv.isDarwin [Cocoa];
+
+ hardeningEnable = lib.optionals stdenv.isLinux ["pie"];
+
+ cmakeFlags =
+ [
+ "-DLauncher_BUILD_PLATFORM=nixpkgs"
+ ]
+ ++ lib.optionals (msaClientID != null) ["-DLauncher_MSA_CLIENT_ID=${msaClientID}"]
+ ++ lib.optionals (lib.versionOlder qtbase.version "6") ["-DLauncher_QT_VERSION_MAJOR=5"]
+ ++ lib.optionals stdenv.isDarwin ["-DINSTALL_BUNDLE=nodeps" "-DMACOSX_SPARKLE_UPDATE_FEED_URL=''"];
+
+ postUnpack = ''
+ rm -rf source/libraries/libnbtplusplus
+ ln -s ${libnbtplusplus} source/libraries/libnbtplusplus
+ '';
+
+ dontWrapQtApps = true;
+
+ meta = with lib; {
+ mainProgram = "prismlauncher";
+ homepage = "https://prismlauncher.org/";
+ description = "A free, open source launcher for Minecraft";
+ 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.
+ '';
+ platforms = with platforms; linux ++ darwin;
+ changelog = "https://github.com/PrismLauncher/PrismLauncher/releases/tag/${version}";
+ license = licenses.gpl3Only;
+ maintainers = with maintainers; [minion3665 Scrumplex getchoo];
+ };
+ }
diff --git a/nix/pkg/wrapper.nix b/nix/pkg/wrapper.nix
new file mode 100644
index 00000000..cd356c8d
--- /dev/null
+++ b/nix/pkg/wrapper.nix
@@ -0,0 +1,95 @@
+{
+ lib,
+ stdenv,
+ symlinkJoin,
+ prismlauncher-unwrapped,
+ wrapQtAppsHook,
+ addOpenGLRunpath,
+ qtbase, # needed for wrapQtAppsHook
+ qtsvg,
+ qtwayland,
+ xorg,
+ libpulseaudio,
+ libGL,
+ glfw,
+ openal,
+ jdk8,
+ jdk17,
+ gamemode,
+ flite,
+ mesa-demos,
+ udev,
+ libusb1,
+ msaClientID ? null,
+ gamemodeSupport ? stdenv.isLinux,
+ textToSpeechSupport ? stdenv.isLinux,
+ controllerSupport ? stdenv.isLinux,
+ jdks ? [jdk17 jdk8],
+ additionalLibs ? [],
+ additionalPrograms ? [],
+}: let
+ prismlauncherFinal = prismlauncher-unwrapped.override {
+ inherit msaClientID gamemodeSupport;
+ };
+in
+ symlinkJoin {
+ name = "prismlauncher-${prismlauncherFinal.version}";
+
+ paths = [prismlauncherFinal];
+
+ nativeBuildInputs = [
+ wrapQtAppsHook
+ ];
+
+ buildInputs =
+ [
+ qtbase
+ qtsvg
+ ]
+ ++ lib.optional (lib.versionAtLeast qtbase.version "6" && stdenv.isLinux) qtwayland;
+
+ postBuild = ''
+ wrapQtAppsHook
+ '';
+
+ qtWrapperArgs = let
+ runtimeLibs =
+ (with xorg; [
+ libX11
+ libXext
+ libXcursor
+ libXrandr
+ libXxf86vm
+ ])
+ ++ [
+ # lwjgl
+ libpulseaudio
+ libGL
+ glfw
+ openal
+ stdenv.cc.cc.lib
+
+ # oshi
+ udev
+ ]
+ ++ lib.optional gamemodeSupport gamemode.lib
+ ++ lib.optional textToSpeechSupport flite
+ ++ lib.optional controllerSupport libusb1
+ ++ additionalLibs;
+
+ runtimePrograms =
+ [
+ xorg.xrandr
+ mesa-demos # need glxinfo
+ ]
+ ++ 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}"
+ # xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
+ "--prefix PATH : ${lib.makeBinPath runtimePrograms}"
+ ];
+
+ inherit (prismlauncherFinal) meta;
+ }