-
Notifications
You must be signed in to change notification settings - Fork 39
/
flake.nix
116 lines (108 loc) · 3.19 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
{
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"];
};
in {
devShells.default = pkgs.mkShell rec {
# build dependencies
nativeBuildInputs = with pkgs; [
# 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_SDK_ROOT = "${androidComposition.androidsdk}/libexec/android-sdk";
ANDROID_NDK_ROOT = "${ANDROID_SDK_ROOT}/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;
}
);
}