forked from Redot-Engine/redot-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
112 lines (105 loc) · 2.8 KB
/
flake.nix
File metadata and controls
112 lines (105 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
{
description = "A Nix-flake-based C/C++ development environment";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = {
self,
nixpkgs,
}: let
supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
forEachSupportedSystem = f:
nixpkgs.lib.genAttrs supportedSystems (system:
f rec {
pkgs = import nixpkgs {inherit system;};
isDarwin = pkgs.lib.hasSuffix system "darwin";
arch = if pkgs.stdenv.hostPlatform.isAarch64 then "arm64" else "x86_64";
linuxDeps = with pkgs; [
autoPatchelfHook
xorg.libX11
xorg.libXcursor
xorg.libXinerama
xorg.libXext
xorg.libXrandr
xorg.libXrender
xorg.libXi
xorg.libXfixes
libxkbcommon
wayland-scanner
wayland
libdecor
alsa-lib
libpulseaudio
udev
dbus
dbus.lib
];
darwinDeps = with pkgs; [
Foundation
Cocoa
AudioToolbox
CoreAudio
CoreVideo
AVFoundation
];
commonDeps = with pkgs; [
pkg-config
installShellFiles
python3
speechd
makeWrapper
mono
dotnet-sdk_8
dotnet-runtime_8
vulkan-loader
libGL
fontconfig
fontconfig.lib
scons
];
deps = if isDarwin then darwinDeps ++ commonDeps else linuxDeps ++ commonDeps;
libraryPathVar = if isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH";
platform = if isDarwin then "macos" else "linuxbsd";
binary = if isDarwin then "redot.macos.editor.${arch}" else "redot.linuxbsd.editor.${arch}";
});
in {
apps = forEachSupportedSystem ({
pkgs,
deps,
libraryPathVar,
platform,
binary,
arch,
...
}: let
script = pkgs.writeShellScript "redot" ''
export ${libraryPathVar}=${pkgs.lib.makeLibraryPath deps}
if [ ! -f ./bin/${binary} ]; then
echo "Building Redot..."
scons platform=${platform}
fi
exec ./bin/${binary} "$@"
'';
in {
default = {
type = "app";
program = "${script}";
};
});
devShells = forEachSupportedSystem ({
pkgs,
deps,
libraryPathVar,
...
}: {
default =
pkgs.mkShell.override
{
# Override stdenv in order to change compiler:
# stdenv = pkgs.clangStdenv;
}
{
packages = deps;
${libraryPathVar} = pkgs.lib.makeLibraryPath deps;
};
});
};
}