Skip to content

Commit d20ae93

Browse files
committed
fix(nix): fix darwin build, remove extra dependency with modern and cool freesmlauncher nix code
Signed-off-by: kaeeraa <kaeeraa@nebula-nook.ru>
1 parent bffc599 commit d20ae93

4 files changed

Lines changed: 83 additions & 105 deletions

File tree

flake.lock

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
inputs = {
1818
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
19-
nix-filter.url = "github:numtide/nix-filter";
2019
libnbtplusplus = {
2120
url = "github:FreesmTeam/libnbtplusplus";
2221
flake = false;
@@ -26,7 +25,6 @@
2625
outputs = {
2726
self,
2827
nixpkgs,
29-
nix-filter,
3028
libnbtplusplus,
3129
...
3230
}: let
@@ -41,7 +39,7 @@
4139
in {
4240
overlays.default = final: prev: {
4341
freesmlauncher-unwrapped = final.callPackage ./nix/unwrapped.nix {
44-
inherit nix-filter libnbtplusplus self;
42+
inherit libnbtplusplus self;
4543
};
4644

4745
freesmlauncher = final.callPackage ./nix/wrapper.nix;
@@ -51,7 +49,7 @@
5149
pkgs = import nixpkgs {inherit system;};
5250

5351
freesmlauncher-unwrapped = pkgs.callPackage ./nix/unwrapped.nix {
54-
inherit nix-filter libnbtplusplus self;
52+
inherit libnbtplusplus self;
5553
};
5654

5755
freesmlauncher = pkgs.callPackage ./nix/wrapper.nix {

nix/unwrapped.nix

Lines changed: 71 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -14,96 +14,87 @@
1414
tomlplusplus,
1515
ghc_filesystem,
1616
libarchive,
17-
darwin,
1817
gamemode,
1918
extra-cmake-modules,
20-
nix-filter,
2119
msaClientID ? null,
2220
gamemodeSupport ? stdenv.hostPlatform.isLinux,
23-
}: let
24-
isDarwin = stdenv.hostPlatform.isDarwin;
25-
in
26-
assert lib.assertMsg (gamemodeSupport -> stdenv.hostPlatform.isLinux)
27-
"gamemodeSupport only on linux";
28-
stdenv.mkDerivation {
29-
pname = "freesmlauncher-unwrapped";
30-
version = self.shortRev or self.dirtyShortRev or "_git";
31-
src = nix-filter.lib {
32-
root = self;
33-
include = [
34-
"buildconfig"
35-
"cmake"
36-
"launcher"
37-
"libraries"
38-
"program_info"
39-
"tests"
40-
../docs/COPYING.md
41-
../CMakeLists.txt
42-
];
21+
}:
22+
assert lib.assertMsg (gamemodeSupport -> stdenv.hostPlatform.isLinux)
23+
"gamemodeSupport only on linux";
24+
stdenv.mkDerivation {
25+
pname = "freesmlauncher-unwrapped";
26+
version = self.shortRev or self.dirtyShortRev or "_git";
27+
src = with lib.fileset;
28+
toSource {
29+
root = ../.;
30+
fileset = unions [
31+
../buildconfig
32+
../cmake
33+
../launcher
34+
../libraries
35+
../program_info
36+
../tests
4337

44-
# Some fetchers leave submodules directories empty instead of omitting them, causing Garnix CI cache misses.
45-
exclude = [
46-
"libraries/libnbtplusplus"
38+
../CMakeLists.txt
39+
../docs/COPYING.md
4740
];
4841
};
4942

50-
postUnpack = ''
51-
ln -s ${libnbtplusplus} source/libraries/libnbtplusplus
52-
'';
43+
postUnpack = let
44+
folder = "source/libraries/libnbtplusplus";
45+
in ''
46+
rm -rf ${folder}
47+
ln -s ${libnbtplusplus} ${folder}
48+
'';
5349

54-
nativeBuildInputs = [
55-
cmake
56-
ninja
57-
extra-cmake-modules
58-
jdk17
59-
stripJavaArchivesHook
60-
];
50+
nativeBuildInputs = [
51+
cmake
52+
ninja
53+
extra-cmake-modules
54+
jdk17
55+
stripJavaArchivesHook
56+
];
6157

62-
buildInputs =
63-
[
64-
cmark
65-
ghc_filesystem
66-
kdePackages.qtbase
67-
kdePackages.qtnetworkauth
68-
kdePackages.quazip
69-
libarchive
70-
tomlplusplus
71-
qrencode
72-
zlib
73-
]
74-
++ lib.optionals isDarwin [darwin.apple_sdk.frameworks.Cocoa]
75-
++ lib.optionals gamemodeSupport [gamemode];
58+
buildInputs =
59+
[
60+
cmark
61+
ghc_filesystem
62+
kdePackages.qtbase
63+
kdePackages.qtnetworkauth
64+
kdePackages.quazip
65+
libarchive
66+
tomlplusplus
67+
qrencode
68+
zlib
69+
]
70+
++ lib.optionals gamemodeSupport [gamemode];
7671

77-
cmakeFlags =
78-
[(lib.cmakeFeature "Launcher_BUILD_PLATFORM" "nixpkgs")]
79-
++ lib.optionals (msaClientID != null) [
80-
(lib.cmakeFeature "Launcher_MSA_CLIENT_ID" msaClientID)
81-
]
82-
++ lib.optionals (lib.versionOlder kdePackages.qtbase.version "6")
83-
[
84-
(lib.cmakeFeature "Launcher_QT_VERSION_MAJOR" "5")
85-
]
86-
++ lib.optionals stdenv.hostPlatform.isDarwin [
87-
(lib.cmakeFeature "INSTALL_BUNDLE" "nodeps")
88-
(lib.cmakeFeature "MACOSX_SPARKLE_UPDATE_FEED_URL" "''")
89-
(lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/Applications/")
90-
];
72+
cmakeFlags =
73+
[(lib.cmakeFeature "Launcher_BUILD_PLATFORM" "nixpkgs")]
74+
++ lib.optionals (msaClientID != null) [
75+
(lib.cmakeFeature "Launcher_MSA_CLIENT_ID" msaClientID)
76+
]
77+
++ lib.optionals stdenv.hostPlatform.isDarwin [
78+
(lib.cmakeFeature "INSTALL_BUNDLE" "nodeps")
79+
(lib.cmakeFeature "MACOSX_SPARKLE_UPDATE_FEED_URL" "''")
80+
(lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/Applications/")
81+
];
9182

92-
doCheck = true;
93-
dontWrapQtApps = true;
94-
enableParallelBuilding = true;
83+
doCheck = true;
84+
dontWrapQtApps = true;
85+
enableParallelBuilding = true;
9586

96-
meta = {
97-
description = "Prism Launcher fork aimed to provide a free way to play Minecraft";
98-
longDescription = ''
99-
Freesm Launcher is a custom launcher for Minecraft that allows you
100-
to easily manage multiple installations of Minecraft at once and login
101-
with offline account without any restrictions.
102-
'';
103-
homepage = "https://freesmlauncher.org/";
104-
license = lib.licenses.gpl3Only;
105-
platforms = lib.platforms.linux ++ lib.platforms.darwin;
106-
mainProgram = "freesmlauncher";
107-
maintainers = with lib.maintainers; [s0me1newithhand7s];
108-
};
109-
}
87+
meta = {
88+
description = "Prism Launcher fork aimed to provide a free way to play Minecraft";
89+
longDescription = ''
90+
Freesm Launcher is a custom launcher for Minecraft that allows you
91+
to easily manage multiple installations of Minecraft at once and login
92+
with offline account without any restrictions.
93+
'';
94+
homepage = "https://freesmlauncher.org/";
95+
license = lib.licenses.gpl3Only;
96+
platforms = lib.platforms.linux ++ lib.platforms.darwin;
97+
mainProgram = "freesmlauncher";
98+
maintainers = with lib.maintainers; [s0me1newithhand7s];
99+
};
100+
}

nix/wrapper.nix

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,22 @@ in
8585
paths = [launcher];
8686
nativeBuildInputs = [kdePackages.wrapQtAppsHook];
8787
buildInputs = with kdePackages;
88-
[qtbase qtsvg]
88+
[qtbase qtsvg qtimageformats]
8989
++ lib.optional (lib.versionAtLeast qtbase.version "6" && isLinux) qtwayland;
9090

91-
postBuild = ''
92-
wrapQtAppsHook
93-
'';
94-
9591
qtWrapperArgs =
9692
["--prefix FREESMLAUNCHER_JAVA_PATHS : ${lib.makeSearchPath "bin/java" jdks}"]
9793
++ lib.optionals isLinux [
9894
"--prefix PATH : ${lib.makeBinPath runtimePrograms}"
9995
"--prefix LD_LIBRARY_PATH : ${addDriverRunpath.driverLink}/lib:${lib.makeLibraryPath runtimeLibs}"
10096
];
97+
98+
postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
99+
if [ -d "$out/Applications/FreesmLauncher.app/Contents/MacOS" ]; then
100+
mkdir -p "$out/bin"
101+
ln -s \
102+
"$out/Applications/FreesmLauncher.app/Contents/MacOS/freesmlauncher" \
103+
"$out/bin/freesmlauncher"
104+
fi
105+
'';
101106
}

0 commit comments

Comments
 (0)