mirror of
https://github.com/BillyOutlast/posthog.git
synced 2026-02-04 03:01:23 +01:00
250 lines
12 KiB
TOML
250 lines
12 KiB
TOML
#
|
|
# This is a Flox environment manifest.
|
|
# Visit flox.dev/docs/concepts/manifest/
|
|
# or see flox-edit(1), manifest.toml(5) for more information.
|
|
#
|
|
# Flox manifest version managed by Flox CLI
|
|
version = 1
|
|
|
|
# List packages you wish to install in your environment inside
|
|
# the `[install]` section.
|
|
[install]
|
|
# Python - Python itself is installed on activation via `uv sync`
|
|
uv = { pkg-path = "uv", pkg-group = "uv", version = "0.8.19" }
|
|
xmlsec = { pkg-path = "xmlsec", version = "1.3.6" }
|
|
freetds = { pkg-path = "freetds" } # For pymssql
|
|
# Node
|
|
nodejs = { pkg-path = "nodejs_22", pkg-group = "nodejs", version = "22.17.0" } # Same maj.min ver as in Dockerfile; diverges from patch ver
|
|
corepack = { pkg-path = "corepack_22", pkg-group = "nodejs", version = "22.17.0" } # Same maj.min as in Dockerfile; diverges from patch ver
|
|
brotli = { pkg-path = "brotli", pkg-group = "nodejs" }
|
|
openssl = { pkg-path = "openssl", version = "3.4.1", pkg-group = "openssl" }
|
|
nodemon = { pkg-path = "nodemon" }
|
|
# Rust toolchain (based on https://flox.dev/docs/cookbook/languages/rust/)
|
|
cargo.pkg-path = "cargo"
|
|
cargo.pkg-group = "rust-toolchain"
|
|
cargo.version = "1.88.0"
|
|
rustc.pkg-path = "rustc"
|
|
rustc.pkg-group = "rust-toolchain"
|
|
clippy.pkg-path = "clippy"
|
|
clippy.pkg-group = "rust-toolchain"
|
|
rustfmt.pkg-path = "rustfmt"
|
|
rustfmt.pkg-group = "rust-toolchain"
|
|
rust-lib-src.pkg-path = "rustPlatform.rustLibSrc"
|
|
rust-lib-src.pkg-group = "rust-toolchain"
|
|
libiconv.pkg-path = "libiconv"
|
|
libiconv.systems = ["aarch64-darwin"]
|
|
libiconv.pkg-group = "rust-toolchain"
|
|
# rust-analyzer should be isolated in its own group, details in cookbook example
|
|
rust-analyzer.pkg-path = "rust-analyzer"
|
|
rust-analyzer.pkg-group = "rust-analyzer"
|
|
# Go
|
|
go = { pkg-path = "go", version = "1.22", pkg-group = "go" }
|
|
# CLI tools
|
|
mprocs = { pkg-path = "mprocs" }
|
|
cmake = { pkg-path = "cmake", version = "3.31.5", pkg-group = "cmake" }
|
|
sqlx-cli = { pkg-path = "sqlx-cli", version = "0.8.3" } # sqlx
|
|
postgresql = { pkg-path = "postgresql_14" } # psql
|
|
ffmpeg.pkg-path = "ffmpeg"
|
|
ngrok = { pkg-path = "ngrok" }
|
|
|
|
# Set environment variables in the `[vars]` section. These variables may not
|
|
# reference one another, and are added to the environment without first
|
|
# expanding them. They are available for use in the `[profile]` and `[hook]`
|
|
# scripts.
|
|
[vars]
|
|
DEBUG = "1"
|
|
POSTHOG_SKIP_MIGRATION_CHECKS = "1"
|
|
DIRENV_LOG_FORMAT = "" # Disable direnv activation logging (in case direnv is present)
|
|
RUST_LOG = "flox=error,flox_rust_sdk=error,flox_watchdog=error" # Suppress Flox logs only (also set in .envrc for early activation)
|
|
OPENSSL_ROOT_DIR = "$FLOX_ENV"
|
|
OPENSSL_LIB_DIR = "$FLOX_ENV/lib"
|
|
DOTENV_FILE = ".env"
|
|
OPENSSL_INCLUDE_DIR = "$FLOX_ENV/include"
|
|
LDFLAGS="-L$FLOX_ENV/lib"
|
|
CPPFLAGS="-I$FLOX_ENV/include"
|
|
UV_PROJECT_ENVIRONMENT = "$FLOX_ENV_CACHE/venv"
|
|
|
|
# The `hook.on-activate` script is run by the *bash* shell immediately upon
|
|
# activating an environment, and will not be invoked if Flox detects that the
|
|
# environment has previously been activated. Variables set by the script will
|
|
# be inherited by `[profile]` scripts defined below. Note that any stdout
|
|
# generated by the script will be redirected to stderr.
|
|
[hook]
|
|
on-activate = '''
|
|
# Guide through installing and configuring direnv if it's not present (optionally)
|
|
|
|
if [[ -t 0 ]] && ! command -v direnv >/dev/null 2>&1 && [ ! -f "$FLOX_ENV_CACHE/.hush-direnv" ]; then
|
|
read -p "👉 For auto-activation of the environment, we recommend direnv (https://direnv.net).
|
|
❓ Would you like direnv to be set up in $(basename "$SHELL") now? (Y/n)" -n 1 -r
|
|
echo
|
|
if [[ $REPLY =~ ^[Yy]$ || -z $REPLY ]]; then
|
|
$FLOX_ENV_CACHE/../env/direnv-setup.sh
|
|
else
|
|
echo "⏭️ Skipping direnv setup. This message will not be shown again, but if you change your mind, just run '.flox/bin/direnv-setup.sh'"
|
|
fi
|
|
touch $FLOX_ENV_CACHE/.hush-direnv
|
|
echo
|
|
fi
|
|
|
|
echo -e "\033[1;36m🔧 Configuring development environment...\033[0m"
|
|
|
|
# Clean up old Flox log files (older than 7 days)
|
|
echo -e " \033[1;34m🧹 Flox logs\033[0m"
|
|
find "$FLOX_ENV_PROJECT/.flox/log" -name "*.log" -type f -mtime +7 -delete 2>/dev/null || true
|
|
echo -e " \033[32m✅ Flox logs cleaned up\033[0m"
|
|
|
|
# Ensure Python virtual environment - Python version is defined in pyproject.toml
|
|
echo -e " \033[1;34m🐍 Python packages\033[0m"
|
|
echo -e " \033[1;33m📦 Setting up Python environment...\033[0m"
|
|
uv sync --quiet
|
|
echo -e " \033[32m✅ Python environment ready\033[0m"
|
|
|
|
# Expose hogli CLI on PATH via the uv-managed virtualenv
|
|
if [ -d "$UV_PROJECT_ENVIRONMENT/bin" ]; then
|
|
ln -sf "$FLOX_ENV_PROJECT/bin/hogli" "$UV_PROJECT_ENVIRONMENT/bin/hogli"
|
|
fi
|
|
|
|
# Install shell completions for hogli in flox environment cache
|
|
# Must run after symlink creation; PYTHONPATH mirrors what bin/hogli does
|
|
HOGLI_COMPLETION_DIR="$FLOX_ENV_CACHE/completions"
|
|
mkdir -p "$HOGLI_COMPLETION_DIR"
|
|
if [ -d "$UV_PROJECT_ENVIRONMENT/bin" ]; then
|
|
PYTHONPATH="$FLOX_ENV_PROJECT/common" "$UV_PROJECT_ENVIRONMENT/bin/python" -m hogli.core.completion --shell bash > "$HOGLI_COMPLETION_DIR/hogli.bash" 2>/dev/null || true
|
|
PYTHONPATH="$FLOX_ENV_PROJECT/common" "$UV_PROJECT_ENVIRONMENT/bin/python" -m hogli.core.completion --shell zsh > "$HOGLI_COMPLETION_DIR/_hogli" 2>/dev/null || true
|
|
fi
|
|
|
|
# Install top-level Node dependencies - This also sets up pre-commit hooks via Husky
|
|
echo -e " \033[1;34m📦 Node packages\033[0m"
|
|
echo -e " \033[1;33m📦 Installing Node dependencies and pre-commits hooks...\033[0m"
|
|
pnpm install --silent
|
|
echo -e " \033[32m✅ Node dependencies installed\033[0m"
|
|
|
|
# Add required entries to /etc/hosts if not present
|
|
echo -e " \033[1;34m💻 System configuration\033[0m"
|
|
echo -e " \033[1;33m💻 Configuring /etc/hosts for IPv4...\033[0m"
|
|
if ! grep -q "127.0.0.1 kafka clickhouse clickhouse-coordinator objectstorage" /etc/hosts; then
|
|
echo "127.0.0.1 kafka clickhouse clickhouse-coordinator objectstorage" | sudo tee -a /etc/hosts 1> /dev/null
|
|
echo -e " \033[32m✅ /etc/hosts amended for IPv4\033[0m"
|
|
else
|
|
echo -e " \033[32m✅ /etc/hosts already contains the required entries\033[0m"
|
|
fi
|
|
|
|
echo -e " \033[1;33m💻 Configuring /etc/hosts for IPv6...\033[0m"
|
|
if ! grep -q "::1 kafka clickhouse clickhouse-coordinator objectstorage" /etc/hosts; then
|
|
echo "::1 kafka clickhouse clickhouse-coordinator objectstorage" | sudo tee -a /etc/hosts 1> /dev/null
|
|
echo -e " \033[32m✅ /etc/hosts amended for IPv6\033[0m"
|
|
else
|
|
echo -e " \033[32m✅ /etc/hosts already contains the required entries\033[0m"
|
|
fi
|
|
|
|
echo -e " \033[1;34m🔑 Environment variables\033[0m"
|
|
if [ -f "$DOTENV_FILE" ]; then
|
|
set -o allexport
|
|
source "$DOTENV_FILE"
|
|
set +o allexport
|
|
echo -e " \033[32m✅ Environment variables loaded from '$DOTENV_FILE' file\033[0m"
|
|
else
|
|
echo -e " \033[31m❌ Environment variables file '$DOTENV_FILE' not found\033[0m"
|
|
fi
|
|
|
|
# The block below only runs when in an interactive shell
|
|
if [[ -t 0 ]]; then
|
|
quotes=(
|
|
# https://github.com/PostHog/posthog.com/blob/cd0ad2e5a96c3ff7d2662ec696a5560022ff318d/src/components/Careers/FounderNote/Audio
|
|
"At PostHog, we don't follow trends, we set them, like records."
|
|
"Be bold, be fearless, and let's lead the way in tech innovation with beast mode."
|
|
"The future belongs to the bold and the strong."
|
|
"Break the mold, push the limits, and let's redefine what's possible with beast mode on."
|
|
"Our best feature? Still in the pipeline."
|
|
"Mindset matters. Stay positive, stay resilient, and keep grinding."
|
|
"Challenges are just opportunities in disguise."
|
|
"Ownership isn't a task, it's a mindset."
|
|
)
|
|
|
|
echo -e "\n\033[1;35m✨ Inspirational James Hawkins quote he never said: ✨\033[0m"
|
|
echo -e "\033[3;36m💭 \"${quotes[$RANDOM % ${#quotes[@]}]}\"\033[0m"
|
|
echo -e "\033[2;90m - James Hawkins (probably)\033[0m"
|
|
|
|
# Visual separator
|
|
echo -e "\n\033[2;90m─────────────────────────────────────────────────────────────\033[0m"
|
|
|
|
# Print intro message
|
|
echo -e "
|
|
\033[3mYou're all set! Here's what you can do:\033[0m
|
|
|
|
\033[32m🚀 Start the development environment:\033[0m
|
|
\033[32mhogli start\033[0m \033[3m# Full stack (default, required for first time running the stack)\033[0m
|
|
\033[32mhogli start --minimal\033[0m \033[3m# Minimal stack (faster startup, lesser memory usage, not all features are included)\033[0m
|
|
\033[32mhogli start --custom <config>\033[0m \033[3m# Use custom mprocs config\033[0m
|
|
|
|
\033[3m📋 Useful processes available in mprocs (press R to start manually):\033[0m
|
|
\033[34m• generate-demo-data\033[0m \033[3m# Create a user with demo data\033[0m
|
|
\033[34m• storybook\033[0m \033[3m# Run our storybook instance locally\033[0m
|
|
\033[34m• hedgebox-dummy\033[0m \033[3m# Demo environment using your local PostHog stack\033[0m
|
|
|
|
\033[2;90m─────────────────────────────────────────────────────────────\033[0m
|
|
|
|
\033[3m💡 Pro tips:\033[0m
|
|
• Use \033[32mhogli start --minimal\033[0m for faster development at the cost of not enabling all of our services
|
|
• Check \033[34mbin/mprocs-*.yaml\033[0m for available process configurations
|
|
• Most processes include hot-reloading on file changes (except migrations)
|
|
• You can run follow-up migrations with \033[32mhogli migrations:run\033[0m
|
|
• Press 'q' in mprocs to quit, 'r' to restart a process
|
|
• Want a clean environment? Simply run \033[32mhogli docker:services:down && hogli start\033[0m
|
|
"
|
|
fi
|
|
'''
|
|
|
|
# Scripts defined in the `[profile]` section are *sourced* by *your shell* and
|
|
# inherit environment variables set in the `[vars]` section and by `[hook]` scripts.
|
|
# The `profile.common` script is sourced by all shells and special care should be
|
|
# taken to ensure compatibility with all shells, after which exactly one of
|
|
# `profile.{bash,fish,tcsh,zsh}` is sourced by the corresponding shell.
|
|
[profile]
|
|
bash = '''
|
|
if [ -f "$HOME/.bash_profile" ]; then
|
|
source "$HOME/.bash_profile"
|
|
# ensure even with your shell prefs in place we know this is a Flox.dev env
|
|
export PS1="\033[47m(flox)\033[0m $PS1"
|
|
fi
|
|
# Ensure flox binaries (especially Node.js) take precedence over system binaries
|
|
export PATH="$FLOX_ENV/bin:$PATH"
|
|
source $UV_PROJECT_ENVIRONMENT/bin/activate
|
|
# Source hogli bash completions
|
|
[ -f "$FLOX_ENV_CACHE/completions/hogli.bash" ] && source "$FLOX_ENV_CACHE/completions/hogli.bash"
|
|
'''
|
|
zsh = '''
|
|
if [[ -f "$HOME/.zshrc" ]]; then
|
|
source "$HOME/.zshrc"
|
|
# ensure even with your shell prefs in place we know this is a Flox.dev env
|
|
export PS1="%K{white}%F{black}(flox)%k%f $PS1"
|
|
fi
|
|
# Ensure flox binaries (especially Node.js) take precedence over system binaries
|
|
export PATH="$FLOX_ENV/bin:$PATH"
|
|
source $UV_PROJECT_ENVIRONMENT/bin/activate
|
|
# Add hogli completions to zsh
|
|
[[ -f "$FLOX_ENV_CACHE/completions/_hogli" ]] && fpath=("$FLOX_ENV_CACHE/completions" $fpath)
|
|
autoload -Uz compinit && compinit -i
|
|
'''
|
|
fish = '''
|
|
# Ensure flox binaries (especially Node.js) take precedence over system binaries
|
|
fish_add_path "$FLOX_ENV/bin"
|
|
source $UV_PROJECT_ENVIRONMENT/bin/activate.fish
|
|
'''
|
|
tcsh = '''
|
|
# Ensure flox binaries (especially Node.js) take precedence over system binaries
|
|
setenv PATH "$FLOX_ENV/bin:$PATH"
|
|
source $UV_PROJECT_ENVIRONMENT/bin/activate.csh
|
|
'''
|
|
|
|
# The `[services]` section of the manifest allows you to define services.
|
|
# Services defined here use the packages provided by the `[install]` section
|
|
# and any variables you've defined in the `[vars]` section or `hook.on-activate` script.
|
|
[services]
|
|
# db.command = "postgres -D $FLOX_ENV_CACHE/postgres"
|
|
|
|
# Additional options can be set in the `[options]` section. Refer to
|
|
# manifest.toml(5) for a list of available options.
|
|
[options]
|
|
systems = ["aarch64-darwin", "aarch64-linux", "x86_64-darwin", "x86_64-linux"]
|