Skip to content

Commit 0e32897

Browse files
authored
Add IDX template configuration to Gemini samples (#2344)
Adds the configuration needed to open a subdirectory as a template in IDX. Configuration is added to two samples that use Gemini -- Dynamic theme and Gemini tasks
1 parent af7b073 commit 0e32897

File tree

6 files changed

+172
-0
lines changed

6 files changed

+172
-0
lines changed

dynamic_theme/.idx/dev.nix

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# To learn more about how to use Nix to configure your environment
2+
# see: https://developers.google.com/idx/guides/customize-idx-env
3+
{ pkgs, ... }: {
4+
# Which nixpkgs channel to use.
5+
channel = "stable-23.11"; # or "unstable"
6+
# Use https://search.nixos.org/packages to find packages
7+
packages = [
8+
pkgs.nodePackages.firebase-tools
9+
pkgs.jdk17
10+
pkgs.unzip
11+
];
12+
# Sets environment variables in the workspace
13+
env = {};
14+
idx = {
15+
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
16+
extensions = [
17+
"Dart-Code.flutter"
18+
"Dart-Code.dart-code"
19+
];
20+
workspace = {
21+
# Runs when a workspace is first created with this `dev.nix` file
22+
onCreate = {
23+
build-flutter = ''
24+
cd /home/user/myapp/android
25+
./gradlew \
26+
--parallel \
27+
-Pverbose=true \
28+
-Ptarget-platform=android-x86 \
29+
-Ptarget=/home/user/myapp/lib/main.dart \
30+
-Pbase-application-name=android.app.Application \
31+
-Pdart-defines=RkxVVFRFUl9XRUJfQ0FOVkFTS0lUX1VSTD1odHRwczovL3d3dy5nc3RhdGljLmNvbS9mbHV0dGVyLWNhbnZhc2tpdC85NzU1MDkwN2I3MGY0ZjNiMzI4YjZjMTYwMGRmMjFmYWMxYTE4ODlhLw== \
32+
-Pdart-obfuscation=false \
33+
-Ptrack-widget-creation=true \
34+
-Ptree-shake-icons=false \
35+
-Pfilesystem-scheme=org-dartlang-root \
36+
assembleDebug
37+
# TODO: Execute web build in debug mode.
38+
# flutter run does this transparently either way
39+
# https://github.com/flutter/flutter/issues/96283#issuecomment-1144750411
40+
# flutter build web --profile --dart-define=Dart2jsOptimization=O0
41+
adb -s localhost:5555 wait-for-device
42+
'';
43+
};
44+
45+
# To run something each time the workspace is (re)started, use the `onStart` hook
46+
};
47+
# Enable previews and customize configuration
48+
previews = {
49+
enable = true;
50+
previews = {
51+
web = {
52+
command = ["flutter" "run" "--machine" "-d" "web-server" "--web-hostname" "0.0.0.0" "--web-port" "$PORT"];
53+
manager = "flutter";
54+
};
55+
android = {
56+
command = ["flutter" "run" "--machine" "-d" "android" "-d" "localhost:5555"];
57+
manager = "flutter";
58+
};
59+
};
60+
};
61+
};
62+
}

dynamic_theme/idx-template.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "Flutter dynamic theme",
3+
"description": "A template for a Flutter app that uses Gemini to dynamically create a theme.",
4+
"icon": "https://www.gstatic.com/images/branding/productlogos/idx/v1/192px.svg",
5+
"params": [],
6+
"host": {
7+
"virtualization": true
8+
}
9+
}

dynamic_theme/idx-template.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# No user-configurable parameters
2+
{ pkgs, ... }: {
3+
packages = [
4+
pkgs.flutter
5+
];
6+
# Shell script that produces the final environment
7+
bootstrap = ''
8+
export HOME=/home/user
9+
export PATH="$PATH":"$HOME/flutter/bin"
10+
11+
cp -rf ${./.} "$out"
12+
chmod -R +w "$out"
13+
rm -rf "$out/.git" "$out/idx-template".{nix,json}
14+
'';
15+
}

gemini_tasks/.idx/dev.nix

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# To learn more about how to use Nix to configure your environment
2+
# see: https://developers.google.com/idx/guides/customize-idx-env
3+
{ pkgs, ... }: {
4+
# Which nixpkgs channel to use.
5+
channel = "stable-23.11"; # or "unstable"
6+
# Use https://search.nixos.org/packages to find packages
7+
packages = [
8+
pkgs.nodePackages.firebase-tools
9+
pkgs.jdk17
10+
pkgs.unzip
11+
];
12+
# Sets environment variables in the workspace
13+
env = {};
14+
idx = {
15+
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
16+
extensions = [
17+
"Dart-Code.flutter"
18+
"Dart-Code.dart-code"
19+
];
20+
workspace = {
21+
# Runs when a workspace is first created with this `dev.nix` file
22+
onCreate = {
23+
build-flutter = ''
24+
cd /home/user/myapp/android
25+
./gradlew \
26+
--parallel \
27+
-Pverbose=true \
28+
-Ptarget-platform=android-x86 \
29+
-Ptarget=/home/user/myapp/lib/main.dart \
30+
-Pbase-application-name=android.app.Application \
31+
-Pdart-defines=RkxVVFRFUl9XRUJfQ0FOVkFTS0lUX1VSTD1odHRwczovL3d3dy5nc3RhdGljLmNvbS9mbHV0dGVyLWNhbnZhc2tpdC85NzU1MDkwN2I3MGY0ZjNiMzI4YjZjMTYwMGRmMjFmYWMxYTE4ODlhLw== \
32+
-Pdart-obfuscation=false \
33+
-Ptrack-widget-creation=true \
34+
-Ptree-shake-icons=false \
35+
-Pfilesystem-scheme=org-dartlang-root \
36+
assembleDebug
37+
# TODO: Execute web build in debug mode.
38+
# flutter run does this transparently either way
39+
# https://github.com/flutter/flutter/issues/96283#issuecomment-1144750411
40+
# flutter build web --profile --dart-define=Dart2jsOptimization=O0
41+
adb -s localhost:5555 wait-for-device
42+
'';
43+
};
44+
45+
# To run something each time the workspace is (re)started, use the `onStart` hook
46+
};
47+
# Enable previews and customize configuration
48+
previews = {
49+
enable = true;
50+
previews = {
51+
web = {
52+
command = ["flutter" "run" "--machine" "-d" "web-server" "--web-hostname" "0.0.0.0" "--web-port" "$PORT"];
53+
manager = "flutter";
54+
};
55+
android = {
56+
command = ["flutter" "run" "--machine" "-d" "android" "-d" "localhost:5555"];
57+
manager = "flutter";
58+
};
59+
};
60+
};
61+
};
62+
}

gemini_tasks/idx-template.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "Todo list with Flutter and Gemini",
3+
"description": "A template for a todo list app that integrates with the Gemini API",
4+
"icon": "https://www.gstatic.com/images/branding/productlogos/idx/v1/192px.svg",
5+
"params": [],
6+
"host": {
7+
"virtualization": true
8+
}
9+
}

gemini_tasks/idx-template.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# No user-configurable parameters
2+
{ pkgs, ... }: {
3+
packages = [
4+
pkgs.flutter
5+
];
6+
# Shell script that produces the final environment
7+
bootstrap = ''
8+
export HOME=/home/user
9+
export PATH="$PATH":"$HOME/flutter/bin"
10+
11+
cp -rf ${./.} "$out"
12+
chmod -R +w "$out"
13+
rm -rf "$out/.git" "$out/idx-template".{nix,json}
14+
'';
15+
}

0 commit comments

Comments
 (0)