Skip to content

Commit 97e7db3

Browse files
Add proper macOS/Darwin support with platform-specific dependencies
1 parent 6d42da8 commit 97e7db3

1 file changed

Lines changed: 42 additions & 19 deletions

File tree

flake.nix

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,10 @@
1212
nixpkgs.lib.genAttrs supportedSystems (system:
1313
f rec {
1414
pkgs = import nixpkgs {inherit system;};
15-
deps = with pkgs; [
16-
pkg-config
15+
isDarwin = pkgs.lib.hasSuffix system "darwin";
16+
17+
linuxDeps = with pkgs; [
1718
autoPatchelfHook
18-
installShellFiles
19-
python3
20-
speechd
21-
wayland-scanner
22-
makeWrapper
23-
mono
24-
dotnet-sdk_8
25-
dotnet-runtime_8
26-
vulkan-loader
27-
libGL
2819
xorg.libX11
2920
xorg.libXcursor
3021
xorg.libXinerama
@@ -34,30 +25,61 @@
3425
xorg.libXi
3526
xorg.libXfixes
3627
libxkbcommon
37-
alsa-lib
28+
wayland-scanner
3829
wayland
3930
libdecor
31+
alsa-lib
4032
libpulseaudio
33+
udev
4134
dbus
4235
dbus.lib
36+
];
37+
38+
darwinDeps = with pkgs; [
39+
Foundation
40+
Cocoa
41+
AudioToolbox
42+
CoreAudio
43+
CoreVideo
44+
AVFoundation
45+
];
46+
47+
commonDeps = with pkgs; [
48+
pkg-config
49+
installShellFiles
50+
python3
51+
speechd
52+
makeWrapper
53+
mono
54+
dotnet-sdk_8
55+
dotnet-runtime_8
56+
vulkan-loader
57+
libGL
4358
fontconfig
4459
fontconfig.lib
45-
udev
4660
scons
4761
];
62+
63+
deps = if isDarwin then darwinDeps ++ commonDeps else linuxDeps ++ commonDeps;
64+
libraryPathVar = if isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH";
65+
platform = if isDarwin then "macos" else "linuxbsd";
66+
binary = if isDarwin then "redot.macos.editor.x86_64" else "redot.linuxbsd.editor.x86_64";
4867
});
4968
in {
5069
apps = forEachSupportedSystem ({
5170
pkgs,
5271
deps,
72+
libraryPathVar,
73+
platform,
74+
binary,
5375
}: let
5476
script = pkgs.writeShellScript "redot" ''
55-
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath deps}
56-
if [ ! -f ./bin/redot.linuxbsd.editor.x86_64 ]; then
77+
export ${libraryPathVar}=${pkgs.lib.makeLibraryPath deps}
78+
if [ ! -f ./bin/${binary} ]; then
5779
echo "Building Redot..."
58-
scons platform=linuxbsd
80+
scons platform=${platform}
5981
fi
60-
exec ./bin/redot.linuxbsd.editor.x86_64 "$@"
82+
exec ./bin/${binary} "$@"
6183
'';
6284
in {
6385
default = {
@@ -69,6 +91,7 @@
6991
devShells = forEachSupportedSystem ({
7092
pkgs,
7193
deps,
94+
libraryPathVar,
7295
}: {
7396
default =
7497
pkgs.mkShell.override
@@ -78,7 +101,7 @@
78101
}
79102
{
80103
packages = deps;
81-
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath deps;
104+
${libraryPathVar} = pkgs.lib.makeLibraryPath deps;
82105
};
83106
});
84107
};

0 commit comments

Comments
 (0)