-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdevNix.j2
More file actions
98 lines (88 loc) · 3.76 KB
/
devNix.j2
File metadata and controls
98 lines (88 loc) · 3.76 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
{% set perPackageManager = {
"npm": {
"packages": "pkgs.nodejs_20",
"install": "npm install --prefer-offline --no-audit --no-progress && npm i react@latest react-dom@latest react-native@latest && npm i -D @types/react@latest",
"android": "npm run android",
"start": "npm start"
},
"yarn": {
"packages": "pkgs.yarn",
"install": "yarn install --frozen-lockfile && yarn add react@latest react-dom@latest react-native@latest && yard add -D @types/react@latest",
"android": "yarn android",
"start": "yarn start"
}
}[packageManager]%}
{ pkgs, ... }: {
channel = "stable-25.05";
packages = [
{{perPackageManager.packages}}
pkgs.jdk21_headless
pkgs.gradle
pkgs.android-tools
pkgs.watchman
pkgs.curl # Add curl for health checking Metro
];
idx = {
extensions = [
"msjsdiag.vscode-react-native"
"dbaeumer.vscode-eslint"
"esbenp.prettier-vscode"
];
workspace = {
onCreate = {
install = ''
# Install dependencies
{{perPackageManager.install}}
# Create local Android SDK directory in home folder
mkdir -p $HOME/.android-sdk-local
export ANDROID_SDK_ROOT=$HOME/.android-sdk-local
export ANDROID_HOME=$ANDROID_SDK_ROOT
rm -rf ~/.gradle/caches/
# Accept Android SDK licenses
mkdir -p $ANDROID_SDK_ROOT/licenses
echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" > $ANDROID_SDK_ROOT/licenses/android-sdk-license
echo "d56f5187479451eabf01fb78af6dfcb131a6481e" >> $ANDROID_SDK_ROOT/licenses/android-sdk-license
echo "84831b9409646a918e30573bab4c9c91346d8abd" > $ANDROID_SDK_ROOT/licenses/android-sdk-preview-license
# Add more memory to the JVM
sed -i 's/org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m/org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m/' "android/gradle.properties"
# Print success message in green
echo -e "\n\033[1;32m╭──────────────────────────────────────────────────────────╮\033[0m"
echo -e "\033[1;32m│ ✓ Dependencies installed successfully! │\033[0m"
echo -e "\033[1;32m│ │\033[0m"
echo -e "\033[1;32m│ Preview initialization in progress... │\033[0m"
echo -e "\033[1;32m│ To view logs: Open Output panel and select IDX │\033[0m"
echo -e "\033[1;32m│ (View > Output > IDX) │\033[0m"
echo -e "\033[1;32m╰──────────────────────────────────────────────────────────╯\033[0m\n"
'';
};
};
previews = {
enable = true;
previews = {
android = {
command = [
"sh"
"-c"
''
# Set the correct emulator to use
export ANDROID_SERIAL=emulator-5554
# Start watchman
watchman watch $PWD
# Set the correct Metro port environment variable
export RCT_METRO_PORT=$PORT
{{perPackageManager.start}} &
METRO_PID=$!
# Wait for Metro to be available
until curl -s http://localhost:$PORT/status > /dev/null; do
sleep 1
done
{{perPackageManager.android}}
wait $METRO_PID
''
];
manager = "web";
};
};
};
};
}