forked from monogramdesign/idx-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevNix.j2
97 lines (97 loc) · 3.55 KB
/
devNix.j2
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
{% set perPackageManager = {
"npm": {
"packages": "pkgs.nodejs_20",
"install": "npm ci --prefer-offline --no-audit --no-progress --timing && npm i @expo/ngrok@^4.1.0",
"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",
"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",
"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",
"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-23.11"; # or "unstable"
# Use https://search.nixos.org/packages to find packages
packages = {% if openIn == "development" %}[{{perPackageManager.packages}} pkgs.nodejs_20 pkgs.jdk21_headless pkgs.gradle pkgs.socat]{% 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 = {
{% if openIn == "development" %}
forward-ports = ''
socat -d -d TCP-LISTEN:5554,reuseaddr,fork TCP:$(cat /etc/resolv.conf | tail -n1 | cut -d " " -f 2):5554
'';
{% endif %}
connect-device = ''
adb -s localhost:5554 wait-for-device
'';
android = ''
{% if openIn == "development" %}
{{packageManager}} run android
{% else %}
{{perPackageManager.previewAndroidPrefix}} --port 5554 --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";
};
};
};
};
}