feat(nix): flake-utils -> flake-parts
Signed-off-by: seth <getchoo@tuta.io>
This commit is contained in:
120
nix/default.nix
120
nix/default.nix
@ -1,100 +1,32 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
cmake,
|
||||
ninja,
|
||||
jdk8,
|
||||
jdk17,
|
||||
zlib,
|
||||
file,
|
||||
wrapQtAppsHook,
|
||||
xorg,
|
||||
libpulseaudio,
|
||||
qtbase,
|
||||
qtsvg,
|
||||
qtwayland,
|
||||
libGL,
|
||||
quazip,
|
||||
glfw,
|
||||
openal,
|
||||
extra-cmake-modules,
|
||||
tomlplusplus,
|
||||
ghc_filesystem,
|
||||
cmark,
|
||||
msaClientID ? "",
|
||||
jdks ? [jdk17 jdk8],
|
||||
gamemodeSupport ? true,
|
||||
gamemode,
|
||||
# flake
|
||||
inputs,
|
||||
self,
|
||||
version,
|
||||
libnbtplusplus,
|
||||
}:
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "prismlauncher";
|
||||
inherit version;
|
||||
|
||||
src = lib.cleanSource self;
|
||||
|
||||
nativeBuildInputs = [extra-cmake-modules cmake file jdk17 ninja wrapQtAppsHook];
|
||||
buildInputs =
|
||||
[
|
||||
qtbase
|
||||
qtsvg
|
||||
zlib
|
||||
quazip
|
||||
ghc_filesystem
|
||||
tomlplusplus
|
||||
cmark
|
||||
]
|
||||
++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland
|
||||
++ lib.optional gamemodeSupport gamemode.dev;
|
||||
|
||||
cmakeFlags =
|
||||
lib.optionals (msaClientID != "") ["-DLauncher_MSA_CLIENT_ID=${msaClientID}"]
|
||||
++ lib.optionals (lib.versionOlder qtbase.version "6") ["-DLauncher_QT_VERSION_MAJOR=5"];
|
||||
|
||||
postUnpack = ''
|
||||
rm -rf source/libraries/libnbtplusplus
|
||||
mkdir source/libraries/libnbtplusplus
|
||||
ln -s ${libnbtplusplus}/* source/libraries/libnbtplusplus
|
||||
chmod -R +r+w source/libraries/libnbtplusplus
|
||||
chown -R $USER: source/libraries/libnbtplusplus
|
||||
'';
|
||||
|
||||
qtWrapperArgs = let
|
||||
libpath = with xorg;
|
||||
lib.makeLibraryPath ([
|
||||
libX11
|
||||
libXext
|
||||
libXcursor
|
||||
libXrandr
|
||||
libXxf86vm
|
||||
libpulseaudio
|
||||
libGL
|
||||
glfw
|
||||
openal
|
||||
stdenv.cc.cc.lib
|
||||
]
|
||||
++ lib.optional gamemodeSupport gamemode.lib);
|
||||
in [
|
||||
"--set LD_LIBRARY_PATH /run/opengl-driver/lib:${libpath}"
|
||||
"--prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}"
|
||||
# xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
|
||||
"--prefix PATH : ${lib.makeBinPath [xorg.xrandr]}"
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
./dev.nix
|
||||
./distribution.nix
|
||||
];
|
||||
|
||||
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];
|
||||
_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"
|
||||
"x86_64-darwin"
|
||||
"aarch64-linux"
|
||||
# Disabled due to qtbase being currently broken for "aarch64-darwin."
|
||||
# "aarch64-darwin"
|
||||
];
|
||||
}
|
||||
|
44
nix/dev.nix
Normal file
44
nix/dev.nix
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
inputs,
|
||||
self,
|
||||
...
|
||||
}: {
|
||||
perSystem = {
|
||||
system,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
checks = {
|
||||
pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
|
||||
src = self;
|
||||
hooks = {
|
||||
markdownlint.enable = true;
|
||||
|
||||
alejandra.enable = true;
|
||||
deadnix.enable = true;
|
||||
|
||||
clang-format = {
|
||||
enable =
|
||||
false; # As most of the codebase is **not** formatted, we don't want clang-format yet
|
||||
types_or = ["c" "c++"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
inherit (self.checks.${system}.pre-commit-check) shellHook;
|
||||
packages = with pkgs; [
|
||||
nodePackages.markdownlint-cli
|
||||
alejandra
|
||||
deadnix
|
||||
clang-tools
|
||||
];
|
||||
|
||||
inputsFrom = [self.packages.${system}.default];
|
||||
buildInputs = with pkgs; [ccache ninja];
|
||||
};
|
||||
|
||||
formatter = pkgs.alejandra;
|
||||
};
|
||||
}
|
27
nix/distribution.nix
Normal file
27
nix/distribution.nix
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
inputs,
|
||||
self,
|
||||
version,
|
||||
...
|
||||
}: {
|
||||
perSystem = {pkgs, ...}: {
|
||||
packages = {
|
||||
inherit (pkgs) prismlauncher prismlauncher-qt5;
|
||||
default = pkgs.prismlauncher;
|
||||
};
|
||||
};
|
||||
|
||||
flake = {
|
||||
overlays.default = _: prev: let
|
||||
# Helper function to build prism against different versions of Qt.
|
||||
mkPrism = qt:
|
||||
qt.callPackage ./package.nix {
|
||||
inherit (inputs) libnbtplusplus;
|
||||
inherit self version;
|
||||
};
|
||||
in {
|
||||
prismlauncher = mkPrism prev.qt6Packages;
|
||||
prismlauncher-qt5 = mkPrism prev.libsForQt5;
|
||||
};
|
||||
};
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ../flake.lock);
|
||||
inherit (lock.nodes.flake-compat.locked) rev narHash;
|
||||
flake-compat = fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/${rev}.tar.gz";
|
||||
sha256 = narHash;
|
||||
};
|
||||
in
|
||||
import flake-compat {src = ../.;}
|
100
nix/package.nix
Normal file
100
nix/package.nix
Normal file
@ -0,0 +1,100 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
cmake,
|
||||
ninja,
|
||||
jdk8,
|
||||
jdk17,
|
||||
zlib,
|
||||
file,
|
||||
wrapQtAppsHook,
|
||||
xorg,
|
||||
libpulseaudio,
|
||||
qtbase,
|
||||
qtsvg,
|
||||
qtwayland,
|
||||
libGL,
|
||||
quazip,
|
||||
glfw,
|
||||
openal,
|
||||
extra-cmake-modules,
|
||||
tomlplusplus,
|
||||
ghc_filesystem,
|
||||
cmark,
|
||||
msaClientID ? "",
|
||||
jdks ? [jdk17 jdk8],
|
||||
gamemodeSupport ? true,
|
||||
gamemode,
|
||||
# flake
|
||||
self,
|
||||
version,
|
||||
libnbtplusplus,
|
||||
}:
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "prismlauncher";
|
||||
inherit version;
|
||||
|
||||
src = lib.cleanSource self;
|
||||
|
||||
nativeBuildInputs = [extra-cmake-modules cmake file jdk17 ninja wrapQtAppsHook];
|
||||
buildInputs =
|
||||
[
|
||||
qtbase
|
||||
qtsvg
|
||||
zlib
|
||||
quazip
|
||||
ghc_filesystem
|
||||
tomlplusplus
|
||||
cmark
|
||||
]
|
||||
++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland
|
||||
++ lib.optional gamemodeSupport gamemode.dev;
|
||||
|
||||
cmakeFlags =
|
||||
lib.optionals (msaClientID != "") ["-DLauncher_MSA_CLIENT_ID=${msaClientID}"]
|
||||
++ lib.optionals (lib.versionOlder qtbase.version "6") ["-DLauncher_QT_VERSION_MAJOR=5"];
|
||||
|
||||
postUnpack = ''
|
||||
rm -rf source/libraries/libnbtplusplus
|
||||
mkdir source/libraries/libnbtplusplus
|
||||
ln -s ${libnbtplusplus}/* source/libraries/libnbtplusplus
|
||||
chmod -R +r+w source/libraries/libnbtplusplus
|
||||
chown -R $USER: source/libraries/libnbtplusplus
|
||||
'';
|
||||
|
||||
qtWrapperArgs = let
|
||||
libpath = with xorg;
|
||||
lib.makeLibraryPath ([
|
||||
libX11
|
||||
libXext
|
||||
libXcursor
|
||||
libXrandr
|
||||
libXxf86vm
|
||||
libpulseaudio
|
||||
libGL
|
||||
glfw
|
||||
openal
|
||||
stdenv.cc.cc.lib
|
||||
]
|
||||
++ lib.optional gamemodeSupport gamemode.lib);
|
||||
in [
|
||||
"--set LD_LIBRARY_PATH /run/opengl-driver/lib:${libpath}"
|
||||
"--prefix PRISMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}"
|
||||
# xorg.xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
|
||||
"--prefix PATH : ${lib.makeBinPath [xorg.xrandr]}"
|
||||
];
|
||||
|
||||
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];
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user