-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
194 lines (168 loc) · 6.36 KB
/
Copy pathflake.nix
File metadata and controls
194 lines (168 loc) · 6.36 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
{
description = "Tauri App Development Environment";
inputs = {
nixpkgs-linux.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-darwin.url = "github:nixos/nixpkgs/nixos-24.11";
flake-utils.url = "github:numtide/flake-utils";
nixgl.url = "github:nix-community/nixGL";
};
outputs = { self, nixpkgs-linux, nixpkgs-darwin, flake-utils, nixgl }:
flake-utils.lib.eachDefaultSystem (system:
let
isLinux = builtins.match ".*linux.*" system != null;
pkgs = import (if isLinux then nixpkgs-linux else nixpkgs-darwin) {
inherit system;
config = {
allowUnfree = true;
android_sdk.accept_license = true;
};
overlays = [ nixgl.overlay ];
};
inherit (pkgs) lib;
pkgsAndroid = import nixpkgs-linux {
inherit system;
config = {
allowUnfree = true;
android_sdk.accept_license = true;
};
};
pkgsUnstable = import nixpkgs-linux {
inherit system;
config.allowUnfree = true;
};
ndkVersion = "26.3.11579264";
androidComposition = if isLinux then pkgsAndroid.androidenv.composeAndroidPackages {
cmdLineToolsVersion = "11.0";
toolsVersion = "26.1.1";
platformToolsVersion = "35.0.1";
buildToolsVersions = [ "35.0.0" ];
includeEmulator = false;
platformVersions = [ "36" ];
includeSources = false;
includeSystemImages = false;
includeNDK = true;
ndkVersions = [ ndkVersion ];
cmakeVersions = [ "3.22.1" ];
useGoogleAPIs = false;
useGoogleTVAddOns = false;
} else null;
androidSdk = if androidComposition != null then androidComposition.androidsdk else null;
linuxLibraries = with pkgs; [
webkitgtk_4_1
gtk3
cairo
gdk-pixbuf
glib
dbus
openssl
librsvg
libayatana-appindicator
libsoup_3
libcanberra-gtk3
mesa
glib-networking
libpulseaudio
alsa-lib
libnice
steam-run
];
linuxGstreamer = with pkgs.gst_all_1; [
gstreamer
gst-plugins-base
gst-plugins-good
gst-plugins-bad
gst-plugins-ugly
gst-libav
];
darwinFrameworks = with pkgs.darwin.apple_sdk.frameworks; [
Security
CoreServices
CoreFoundation
Foundation
AppKit
WebKit
] ++ [ pkgs.libiconv ];
commonPackages = with pkgs; [
rustup
cargo
cargo-tauri
nodejs_22
curl
wget
file
gnumake
binutils
just
pkg-config
typescript
bun
] ++ [
pkgsUnstable.just
];
in
{
devShells.default = pkgs.mkShell {
buildInputs = commonPackages
++ lib.optionals isLinux (linuxLibraries ++ linuxGstreamer)
++ lib.optionals (!isLinux) darwinFrameworks;
nativeBuildInputs = with pkgs; [ pkg-config ]
++ lib.optionals isLinux [ wrapGAppsHook4 xdotool pkgs.nixgl.auto.nixGLNvidia ];
packages = lib.optionals isLinux [
androidSdk
pkgs.gradle
pkgs.jdk17
];
shellHook = ''
# --- Android Setup (Linux Only) ---
${lib.optionalString isLinux ''
export ANDROID_HOME=${androidSdk}/libexec/android-sdk
export NDK_HOME=${androidSdk}/libexec/android-sdk/ndk/${ndkVersion}
# Force Gradle to use the build-tools version we actually have installed
export GRADLE_OPTS="-Dorg.gradle.project.android.aapt2FromMavenOverride=${androidSdk}/libexec/android-sdk/build-tools/35.0.0/aapt2"
# NDK Toolchain Setup
export NDK_TOOLCHAIN="$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin"
export CC_aarch64_linux_android="$NDK_TOOLCHAIN/aarch64-linux-android24-clang"
export CXX_aarch64_linux_android="$NDK_TOOLCHAIN/aarch64-linux-android24-clang++"
export AR_aarch64_linux_android="$NDK_TOOLCHAIN/llvm-ar"
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="$NDK_TOOLCHAIN/aarch64-linux-android24-clang"
# Rust Target Initialization
for target in aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android; do
if ! rustup target list --installed | grep -q "^$target$"; then
echo "Initializing Android target: $target"
rustup target add "$target"
fi
done
''}
# --- Linux Hooks (GStreamer / WebKit / Nvidia) ---
${lib.optionalString isLinux ''
export LD_LIBRARY_PATH=${lib.makeLibraryPath (linuxLibraries ++ linuxGstreamer)}:$LD_LIBRARY_PATH
export GIO_MODULE_DIR="${pkgs.glib-networking}/lib/gio/modules/"
export GST_PLUGIN_SYSTEM_PATH_1_0=${lib.concatMapStringsSep ":" (pkg: "${pkg}/lib/gstreamer-1.0") (with pkgs.gst_all_1; [
gstreamer.out
gst-plugins-base
gst-plugins-good
gst-plugins-bad
gst-plugins-ugly
gst-libav
] ++ [ pkgs.libnice ])}
export GST_PLUGIN_PATH=$GST_PLUGIN_SYSTEM_PATH_1_0
# Nvidia hardware acceleration
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export __GL_GSYNC_ALLOWED=1
export __GL_VRR_ALLOWED=1
export LIBVA_DRIVER_NAME=nvidia
export VDPAU_DRIVER=nvidia
export LIBGL_ALWAYS_SOFTWARE=0
export WEBKIT_FORCE_COMPOSITING_MODE=1
export NVD_BACKEND=direct
export GST_VAAPI_ALL_DRIVERS=1
export WEBKIT_FORCE_SANDBOX=0
export WEBKIT_DISABLE_COMPOSITING_MODE=0
export WEBKIT_DISABLE_DMABUF_RENDERER=1
export XDG_DATA_DIRS="${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$GSETTINGS_SCHEMAS_PATH:$XDG_DATA_DIRS"
''}
'';
};
}
);
}