-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdevNix.j2
More file actions
92 lines (92 loc) · 3.73 KB
/
devNix.j2
File metadata and controls
92 lines (92 loc) · 3.73 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
{% set perPackageManager = {
"npm": {
"packages": "pkgs.nodejs_20",
"install": "npm ci --prefer-offline --no-audit --no-progress --timing && npm i @expo/ngrok@^4.1.0 react@latest react-dom@latest react-native@latest && npm i -D @types/react@latest",
"previewWebPrefix": "\"npm\" \"run\" \"web\" \"--\"",
"previewAndroidPrefix": "npm run android --",
"installDevClient": "npx -y expo install expo-dev-client"
},
"bun": {
"packages": "pkgs.bun",
"install": "bun i @expo/ngrok@^4.1.0 react@latest react-dom@latest react-native@latest && bun i -D @types/react@latest",
"previewWebPrefix": "\"bun\" \"web\"",
"previewAndroidPrefix": "bun android",
"installDevClient": "bunx expo install expo-dev-client"
},
"pnpm": {
"packages": "pkgs.nodePackages.pnpm",
"install": "pnpm add @expo/ngrok@^4.1.0 react@latest react-dom@latest react-native@latest && pnpm i -D @types/react@latest",
"previewWebPrefix": "\"pnpm\" \"web\"",
"previewAndroidPrefix": "pnpm android",
"installDevClient": "pnpx expo install expo-dev-client"
},
"yarn": {
"packages": "pkgs.yarn",
"install": "yarn && yarn add @expo/ngrok@^4.1.0 react@latest react-dom@latest react-native@latest && yard add -D @types/react@latest",
"previewWebPrefix": "\"yarn\" \"web\"",
"previewAndroidPrefix": "yarn android",
"installDevClient": "yarn dlx expo install expo-dev-client"
},
}[packageManager]%}# To learn more about how to use Nix to configure your environment
# see: https://developers.google.com/idx/guides/customize-idx-env
{ pkgs, ... }: {
# Which nixpkgs channel to use.
channel = "stable-25.05";
# Use https://search.nixos.org/packages to find packages
packages = {% if openIn == "development" %}[{{perPackageManager.packages}} pkgs.nodejs_20 pkgs.jdk21_headless pkgs.gradle]{% else %}[{{perPackageManager.packages}}]{% endif %};
# Sets environment variables in the workspace
env = {
EXPO_USE_FAST_RESOLVER = 1;
};
idx = {
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
extensions = [
"msjsdiag.vscode-react-native"
{% if openIn == "development" %}
"fwcd.kotlin"
{% endif %}
];
workspace = {
# Runs when a workspace is first created with this `dev.nix` file
onCreate = {
{% if openIn == "development" %}
install-and-prebuild = ''
{{perPackageManager.install}} && {{perPackageManager.installDevClient}} && npx -y expo prebuild --platform android
# 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"
'';
{% else %}
install = "{{perPackageManager.install}}";
{% endif %}
};
# Runs when a workspace restarted
onStart = {
android = ''
echo -e "\033[1;33mWaiting for Android emulator to be ready...\033[0m"
# Wait for the device connection command to finish
adb -s emulator-5554 wait-for-device && \
{% if openIn == "development" %}
{{packageManager}} run android
{% else %}
{{perPackageManager.previewAndroidPrefix}} --tunnel
{% endif %}
'';
};
};
# Enable previews and customize configuration
previews = {
enable = true;
previews = {
web = {
command = [{{perPackageManager.previewWebPrefix}} "--port" "$PORT"];
manager = "web";
};
android = {
# noop
command = ["tail" "-f" "/dev/null"];
manager = "web";
};
};
};
};
}