-
Notifications
You must be signed in to change notification settings - Fork 39
/
flake.nix
135 lines (123 loc) · 3.57 KB
/
flake.nix
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{ self
, nixpkgs
, fenix
, flake-utils
,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
# setup pkgs
pkgs = import nixpkgs {
inherit system;
overlays = [ fenix.overlays.default ];
config = {
android_sdk.accept_license = true;
allowUnfree = true;
};
};
# the entire rust toolchain with required targets
rustToolchain = with fenix.packages.${system};
combine [
(stable.withComponents [
"rustc"
"cargo"
"rustfmt"
"clippy"
"rust-src"
])
targets.wasm32-unknown-unknown.stable.rust-std
targets.aarch64-linux-android.stable.rust-std
targets.x86_64-pc-windows-gnu.stable.rust-std
];
androidComposition = pkgs.androidenv.composeAndroidPackages {
abiVersions = [ "arm64-v8a" ];
includeNDK = true;
platformVersions = [ "32" ];
};
androidStudio = pkgs.android-studio.withSdk androidComposition.androidsdk;
xbuild = pkgs.callPackage ./xbuild { };
in
{
packages.default = xbuild;
devShells.default = pkgs.mkShell rec {
# build dependencies
nativeBuildInputs = with pkgs; [
jdk
kotlin
gradle
squashfsTools
clang
lldb
libllvm
lld
androidComposition.androidsdk
# the entire rust toolchain
rustToolchain
# tool for cross compiling
cargo-apk
xbuild
pkg-config
openssl
# Common cargo tools we often use
cargo-deny
cargo-expand
cargo-binutils
# cmake for openxr
cmake
];
# runtime dependencies
buildInputs =
[
pkgs.zstd
pkgs.libxml2
]
++ pkgs.lib.optionals pkgs.stdenv.isLinux (with pkgs; [
# bevy dependencies
udev
alsa-lib
# vulkan
vulkan-loader
vulkan-headers
vulkan-tools
vulkan-validation-layers
# x11
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
# wayland
libxkbcommon
wayland
# xr
openxr-loader
libGL
])
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.Cocoa
# # This is missing on mac m1 nix, for some reason.
# # see https://stackoverflow.com/a/69732679
pkgs.libiconv
];
# android vars
ANDROID_HOME = "${androidComposition.androidsdk}/libexec/android-sdk";
ANDROID_NDK_ROOT = "${ANDROID_HOME}/ndk-bundle";
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
# this is most likely not needed. for some reason shadows flicker without it.
AMD_VULKAN_ICD = "RADV";
};
# This only formats the nix files.
formatter = pkgs.nixpkgs-fmt;
}
);
}