init
This commit is contained in:
commit
1b5242781b
|
|
@ -0,0 +1,2 @@
|
||||||
|
[safe]
|
||||||
|
directory = /home/coder
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/linux,perl,perl6
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=linux,perl,perl6
|
||||||
|
|
||||||
|
### Linux ###
|
||||||
|
*~
|
||||||
|
|
||||||
|
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||||
|
.fuse_hidden*
|
||||||
|
|
||||||
|
# KDE directory preferences
|
||||||
|
.directory
|
||||||
|
|
||||||
|
# Linux trash folder which might appear on any partition or disk
|
||||||
|
.Trash-*
|
||||||
|
|
||||||
|
# .nfs files are created when an open file is removed but is still being accessed
|
||||||
|
.nfs*
|
||||||
|
|
||||||
|
### Perl ###
|
||||||
|
!Build/
|
||||||
|
.last_cover_stats
|
||||||
|
/META.yml
|
||||||
|
/META.json
|
||||||
|
/MYMETA.*
|
||||||
|
*.o
|
||||||
|
*.pm.tdy
|
||||||
|
*.bs
|
||||||
|
|
||||||
|
# Devel::Cover
|
||||||
|
cover_db/
|
||||||
|
|
||||||
|
# Devel::NYTProf
|
||||||
|
nytprof.out
|
||||||
|
|
||||||
|
# Dist::Zilla
|
||||||
|
/.build/
|
||||||
|
|
||||||
|
# Module::Build
|
||||||
|
_build/
|
||||||
|
Build
|
||||||
|
Build.bat
|
||||||
|
|
||||||
|
# Module::Install
|
||||||
|
inc/
|
||||||
|
|
||||||
|
# ExtUtils::MakeMaker
|
||||||
|
/blib/
|
||||||
|
/_eumm/
|
||||||
|
/*.gz
|
||||||
|
/Makefile
|
||||||
|
/Makefile.old
|
||||||
|
/MANIFEST.bak
|
||||||
|
/pm_to_blib
|
||||||
|
/*.zip
|
||||||
|
|
||||||
|
# Carton
|
||||||
|
local/
|
||||||
|
|
||||||
|
### Perl6 ###
|
||||||
|
# Gitignore for Perl 6 (http://www.perl6.org)
|
||||||
|
# As part of https://github.com/github/gitignore
|
||||||
|
|
||||||
|
# precompiled files
|
||||||
|
.precomp
|
||||||
|
lib/.precomp
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/linux,perl,perl6
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
Get started by customizing your environment (defined in the .idx/dev.nix file) with the tools and IDE extensions you'll need for your project!
|
||||||
|
|
||||||
|
Learn more at https://developers.google.com/idx/guides/customize-idx-env
|
||||||
|
|
@ -0,0 +1,186 @@
|
||||||
|
# Gemini AI Rules for Firebase Studio Nix Projects
|
||||||
|
|
||||||
|
## 1. Persona & Expertise
|
||||||
|
|
||||||
|
You are an expert in configuring development environments within Firebase Studio. You are proficient in using the `dev.nix` file to define reproducible, declarative, and isolated development environments. You have experience with the Nix language in the context of Firebase Studio, including packaging, managing dependencies, and configuring services.
|
||||||
|
|
||||||
|
## 2. Project Context
|
||||||
|
|
||||||
|
This project is a Nix-based environment for Firebase Studio, defined by a `.idx/dev.nix` file. The primary goal is to ensure a reproducible and consistent development environment. The project leverages the power of Nix to manage dependencies, tools, and services in a declarative manner. **Note:** This is not a Nix Flake-based environment.
|
||||||
|
|
||||||
|
## 3. `dev.nix` Configuration
|
||||||
|
|
||||||
|
The `.idx/dev.nix` file is the single source of truth for the development environment. Here are some of the most common configuration options:
|
||||||
|
|
||||||
|
### `channel`
|
||||||
|
The `nixpkgs` channel determines which package versions are available.
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ pkgs, ... }: {
|
||||||
|
channel = "stable-24.05"; # or "unstable"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `packages`
|
||||||
|
A list of packages to install from the specified channel. You can search for packages on the [NixOS package search](https://search.nixos.org/packages).
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ pkgs, ... }: {
|
||||||
|
packages = [
|
||||||
|
pkgs.nodejs_20
|
||||||
|
pkgs.go
|
||||||
|
];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `env`
|
||||||
|
A set of environment variables to define within the workspace.
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ pkgs, ... }: {
|
||||||
|
env = {
|
||||||
|
API_KEY = "your-secret-key";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `idx.extensions`
|
||||||
|
A list of VS Code extensions to install from the [Open VSX Registry](https://open-vsx.org/).
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ pkgs, ... }: {
|
||||||
|
idx = {
|
||||||
|
extensions = [
|
||||||
|
"vscodevim.vim"
|
||||||
|
"golang.go"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `idx.workspace`
|
||||||
|
Workspace lifecycle hooks.
|
||||||
|
|
||||||
|
- **`onCreate`:** Runs when a workspace is first created.
|
||||||
|
- **`onStart`:** Runs every time the workspace is (re)started.
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ pkgs, ... }: {
|
||||||
|
idx = {
|
||||||
|
workspace = {
|
||||||
|
onCreate = {
|
||||||
|
npm-install = "npm install";
|
||||||
|
};
|
||||||
|
onStart = {
|
||||||
|
start-server = "npm run dev";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### `idx.previews`
|
||||||
|
Configure a web preview for your application. The `$PORT` variable is dynamically assigned.
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ pkgs, ... }: {
|
||||||
|
idx = {
|
||||||
|
previews = {
|
||||||
|
enable = true;
|
||||||
|
previews = {
|
||||||
|
web = {
|
||||||
|
command = ["npm" "run" "dev" "--" "--port" "$PORT"];
|
||||||
|
manager = "web";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. Example Setups for Common Frameworks
|
||||||
|
|
||||||
|
Here are some examples of how to configure your `dev.nix` for common languages and frameworks.
|
||||||
|
|
||||||
|
### Node.js Web Server
|
||||||
|
This example sets up a Node.js environment, installs dependencies, and runs a development server with a web preview.
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ pkgs, ... }: {
|
||||||
|
packages = [ pkgs.nodejs_20 ];
|
||||||
|
idx = {
|
||||||
|
extensions = [ "dbaeumer.vscode-eslint" ];
|
||||||
|
workspace = {
|
||||||
|
onCreate = {
|
||||||
|
npm-install = "npm install";
|
||||||
|
};
|
||||||
|
onStart = {
|
||||||
|
dev-server = "npm run dev";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
previews = {
|
||||||
|
enable = true;
|
||||||
|
previews = {
|
||||||
|
web = {
|
||||||
|
command = ["npm" "run" "dev" "--" "--port" "$PORT"];
|
||||||
|
manager = "web";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Python with Flask
|
||||||
|
This example sets up a Python environment for a Flask web server. Remember to create a `requirements.txt` file with `Flask` in it.
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ pkgs, ... }: {
|
||||||
|
packages = [ pkgs.python3 pkgs.pip ];
|
||||||
|
idx = {
|
||||||
|
extensions = [ "ms-python.python" ];
|
||||||
|
workspace = {
|
||||||
|
onCreate = {
|
||||||
|
pip-install = "pip install -r requirements.txt";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
previews = {
|
||||||
|
enable = true;
|
||||||
|
previews = {
|
||||||
|
web = {
|
||||||
|
command = ["flask" "run" "--port" "$PORT"];
|
||||||
|
manager = "web";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Go CLI
|
||||||
|
This example sets up a Go environment for building a command-line interface.
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{ pkgs, ... }: {
|
||||||
|
packages = [ pkgs.go ];
|
||||||
|
idx = {
|
||||||
|
extensions = [ "golang.go" ];
|
||||||
|
workspace = {
|
||||||
|
onCreate = {
|
||||||
|
go-mod = "go mod tidy";
|
||||||
|
};
|
||||||
|
onStart = {
|
||||||
|
run-app = "go run .";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## 5. Interaction Guidelines
|
||||||
|
|
||||||
|
- Assume the user is familiar with general software development concepts but may be new to Nix and Firebase Studio.
|
||||||
|
- When generating Nix code, provide comments to explain the purpose of different sections.
|
||||||
|
- Explain the benefits of using `dev.nix` for reproducibility and dependency management.
|
||||||
|
- If a request is ambiguous, ask for clarification on the desired tools, libraries, and versions to be included in the environment.
|
||||||
|
- When suggesting changes to `dev.nix`, explain the impact of the changes on the development environment and remind the user to reload the environment.
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
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-24.05"; # or "unstable"
|
||||||
|
# Use https://search.nixos.org/packages to find packages
|
||||||
|
packages = [
|
||||||
|
# pkgs.go
|
||||||
|
# pkgs.python311
|
||||||
|
# pkgs.python311Packages.pip
|
||||||
|
# pkgs.nodejs_20
|
||||||
|
# pkgs.nodePackages.nodemon
|
||||||
|
pkgs.perl
|
||||||
|
];
|
||||||
|
# Sets environment variables in the workspace
|
||||||
|
env = {};
|
||||||
|
idx = {
|
||||||
|
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
|
||||||
|
extensions = [
|
||||||
|
# "vscodevim.vim"
|
||||||
|
"google.gemini-cli-vscode-ide-companion"
|
||||||
|
];
|
||||||
|
# Enable previews
|
||||||
|
previews = {
|
||||||
|
enable = true;
|
||||||
|
previews = {
|
||||||
|
# web = {
|
||||||
|
# # Example: run "npm run dev" with PORT set to IDX's defined port for previews,
|
||||||
|
# # and show it in IDX's web preview panel
|
||||||
|
# command = ["npm" "run" "dev"];
|
||||||
|
# manager = "web";
|
||||||
|
# env = {
|
||||||
|
# # Environment variables to set for your server
|
||||||
|
# PORT = "$PORT";
|
||||||
|
# };
|
||||||
|
# };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
# Workspace lifecycle hooks
|
||||||
|
workspace = {
|
||||||
|
# Runs when a workspace is first created
|
||||||
|
onCreate = {
|
||||||
|
# Example: install JS dependencies from NPM
|
||||||
|
# npm-install = "npm install";
|
||||||
|
# Open editors for the following files by default, if they exist:
|
||||||
|
default.openFiles = [ ".idx/dev.nix" "README.md" ];
|
||||||
|
};
|
||||||
|
# Runs when the workspace is (re)started
|
||||||
|
onStart = {
|
||||||
|
# Example: start a background task to watch and re-build backend code
|
||||||
|
# watch-backend = "npm run watch-backend";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": ".."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
{
|
||||||
|
package MyWebServer;
|
||||||
|
use HTTP::Server::Simple::CGI;
|
||||||
|
use base qw(HTTP::Server::Simple::CGI);
|
||||||
|
my %dispatch = (
|
||||||
|
'/hello' => \&resp_hello,
|
||||||
|
# ...
|
||||||
|
);
|
||||||
|
sub handle_request {
|
||||||
|
my $self = shift;
|
||||||
|
my $cgi = shift;
|
||||||
|
|
||||||
|
my $path = $cgi->path_info();
|
||||||
|
my $handler = $dispatch{$path};
|
||||||
|
if (ref($handler) eq "CODE") {
|
||||||
|
print "HTTP/1.0 200 OK\r\n";
|
||||||
|
$handler->($cgi);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
print "HTTP/1.0 404 Not found\r\n";
|
||||||
|
print $cgi->header,
|
||||||
|
$cgi->start_html('Not found'),
|
||||||
|
$cgi->h1('Not found'),
|
||||||
|
$cgi->end_html;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sub resp_hello {
|
||||||
|
my $cgi = shift; # CGI.pm object
|
||||||
|
return if !ref $cgi;
|
||||||
|
|
||||||
|
my $who = $cgi->param('name');
|
||||||
|
|
||||||
|
print $cgi->header,
|
||||||
|
$cgi->start_html("Hello"),
|
||||||
|
$cgi->h1("Hello $who!"),
|
||||||
|
$cgi->end_html;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# start the server on port 8080
|
||||||
|
my $pid = MyWebServer->new(8080)->background();
|
||||||
|
print "Use 'kill $pid' to stop server.\n";
|
||||||
Loading…
Reference in New Issue