refactor(nix): don't instantiate nixpkgs
See https://zimbatm.com/notes/1000-instances-of-nixpkgs Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
e4e4c4a430
commit
bdc2fca711
14
flake.nix
14
flake.nix
@ -23,5 +23,17 @@
|
|||||||
outputs = inputs:
|
outputs = inputs:
|
||||||
inputs.flake-parts.lib.mkFlake
|
inputs.flake-parts.lib.mkFlake
|
||||||
{inherit inputs;}
|
{inherit inputs;}
|
||||||
{imports = [./nix];};
|
{
|
||||||
|
imports = [
|
||||||
|
./nix/dev.nix
|
||||||
|
./nix/distribution.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
systems = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"aarch64-linux"
|
||||||
|
"x86_64-darwin"
|
||||||
|
"aarch64-darwin"
|
||||||
|
];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,31 +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"
|
|
||||||
"x86_64-darwin"
|
|
||||||
"aarch64-darwin"
|
|
||||||
];
|
|
||||||
}
|
|
@ -1,30 +1,32 @@
|
|||||||
{
|
{
|
||||||
inputs,
|
inputs,
|
||||||
self,
|
self,
|
||||||
version,
|
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
perSystem = {pkgs, ...}: {
|
perSystem = {pkgs, ...}: {
|
||||||
packages = {
|
packages = let
|
||||||
inherit (pkgs) prismlauncher-qt5-unwrapped prismlauncher-qt5 prismlauncher-unwrapped prismlauncher;
|
ourPackages = self.overlays.default pkgs null;
|
||||||
default = pkgs.prismlauncher;
|
in {
|
||||||
|
inherit (ourPackages) prismlauncher-qt5-unwrapped prismlauncher-qt5 prismlauncher-unwrapped prismlauncher;
|
||||||
|
default = ourPackages.prismlauncher;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
flake = {
|
flake = {
|
||||||
overlays.default = final: prev: let
|
overlays.default = final: _: let
|
||||||
# Helper function to build prism against different versions of Qt.
|
version = builtins.substring 0 8 self.lastModifiedDate;
|
||||||
mkPrism = qt:
|
|
||||||
qt.callPackage ./package.nix {
|
# common args for prismlauncher evaluations
|
||||||
|
unwrappedArgs = {
|
||||||
inherit (inputs) libnbtplusplus;
|
inherit (inputs) libnbtplusplus;
|
||||||
inherit (prev.darwin.apple_sdk.frameworks) Cocoa;
|
inherit (final.darwin.apple_sdk.frameworks) Cocoa;
|
||||||
inherit self version;
|
inherit self version;
|
||||||
};
|
};
|
||||||
in {
|
in rec {
|
||||||
prismlauncher-qt5-unwrapped = mkPrism final.libsForQt5;
|
prismlauncher-qt5-unwrapped = final.libsForQt5.callPackage ./pkg unwrappedArgs;
|
||||||
prismlauncher-qt5 = prev.prismlauncher-qt5.override {prismlauncher-unwrapped = final.prismlauncher-qt5-unwrapped;};
|
prismlauncher-qt5 = final.libsForQt5.callPackage ./pkg/wrapper.nix {prismlauncher-unwrapped = prismlauncher-qt5-unwrapped;};
|
||||||
prismlauncher-unwrapped = mkPrism final.qt6Packages;
|
prismlauncher-unwrapped = final.qt6Packages.callPackage ./pkg unwrappedArgs;
|
||||||
prismlauncher = prev.prismlauncher.override {inherit (final) prismlauncher-unwrapped;};
|
prismlauncher = final.qt6Packages.callPackage ./pkg/wrapper.nix {inherit prismlauncher-unwrapped;};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
86
nix/pkg/wrapper.nix
Normal file
86
nix/pkg/wrapper.nix
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
stdenv,
|
||||||
|
symlinkJoin,
|
||||||
|
prismlauncher-unwrapped,
|
||||||
|
wrapQtAppsHook,
|
||||||
|
qtbase, # needed for wrapQtAppsHook
|
||||||
|
qtsvg,
|
||||||
|
qtwayland,
|
||||||
|
xorg,
|
||||||
|
libpulseaudio,
|
||||||
|
libGL,
|
||||||
|
glfw,
|
||||||
|
openal,
|
||||||
|
jdk8,
|
||||||
|
jdk17,
|
||||||
|
gamemode,
|
||||||
|
flite,
|
||||||
|
mesa-demos,
|
||||||
|
msaClientID ? null,
|
||||||
|
gamemodeSupport ? stdenv.isLinux,
|
||||||
|
textToSpeechSupport ? 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
|
||||||
|
])
|
||||||
|
++ [
|
||||||
|
libpulseaudio
|
||||||
|
libGL
|
||||||
|
glfw
|
||||||
|
openal
|
||||||
|
stdenv.cc.cc.lib
|
||||||
|
]
|
||||||
|
++ lib.optional gamemodeSupport gamemode.lib
|
||||||
|
++ lib.optional textToSpeechSupport flite
|
||||||
|
++ 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 /run/opengl-driver/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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user