This Flox environment provides a streamlined setup for PostgreSQL database development using Harlequin, a modern SQL IDE in your terminal. The environment automates configuration, connection management, and provides helpful utilities to make your database workflow smooth and efficient.
- Automatic configuration of Harlequin for PostgreSQL connections
- Smart detection of existing PostgreSQL environments
- TUI-based configuration wizard for first-time setup
- Persistent connection configuration storage
- Connection testing and validation utilities
- Database information viewer
- Cross-platform compatibility (macOS, Linux)
The environment packs these essential tools:
harlequin- Modern terminal-based SQL IDE with syntax highlightingharlequin-postgres- PostgreSQL adapter for Harlequingum- Terminal UI toolkit powering the setup wizard and stylingglibcLocalesUtf8- UTF-8 locale support for Linux systemsbat- Bettercatwith syntax highlighting
- PostgreSQL database (local or remote)
- Flox installed on your system
Jump in with:
- Clone this repo or create a new directory
git clone https://github.com/youruser/harlequin-postgres-env && cd harlequin-postgres-env- Run:
flox activateThis command:
- Pulls in all dependencies
- Detects any existing PostgreSQL configuration
- Fires up the configuration wizard if needed
- Drops you into the Flox env with Harlequin ready to go
First-time activation triggers a wizard that:
- Looks for existing PostgreSQL configuration in environment variables
- Checks for a PostgreSQL config file if environment variables aren't found
- Offers to customize your Harlequin configuration if no valid configuration is found
- Saves your configuration for future use
After setup, you have access to these commands:
# Launch Harlequin SQL IDE
harlequin
# Edit your Harlequin configuration
editconf
# Test your PostgreSQL connection
pgtest
# Test your Harlequin database connection
hqtest
# Display database information
dbinfo
# Sync Harlequin settings from PostgreSQL config
hqsync
# Reset Harlequin configuration to defaults
hqreset
# Validate your connection string
hqvalidateThe environment implements a multi-tiered configuration strategy:
- Existing Environment Variables: Uses PostgreSQL environment variables if available
- PostgreSQL Config File: Reads from
postgres.configif present - Harlequin Config File: Uses
harlequin.envif it exists - Interactive Configuration: Prompts for configuration details if no valid config is found
Configuration files are stored in:
- The directory specified by
DEFAULT_PGDIRenvironment variable (if set) - The directory specified by
PGDIRenvironment variable (if set) - The current working directory (fallback)
The environment includes Bash integration with helper functions that:
- Launch Harlequin with the correct connection parameters
- Allow editing configuration files with your preferred editor
- Provide utilities for testing connections and viewing database information
Harlequin provides a powerful interface for:
- Writing and executing SQL queries
- Exploring database schema
- Viewing query results
- Syntax highlighting for SQL
If you encounter issues:
-
Connection fails:
- Run
pgtestorhqtestto check your connection - Verify your PostgreSQL server is running
- Check your connection details with
hqvalidate
- Run
-
Configuration issues:
- Use
editconfto manually edit your Harlequin configuration - Run
hqresetto reset to default configuration - Run
hqsyncto sync from PostgreSQL configuration
- Use
-
Database viewing problems:
- Ensure your database user has appropriate permissions
- Check that your database exists with
dbinfo
This works on:
- macOS (ARM64, x86_64)
- Linux (ARM64, x86_64)
- Harlequin configuration is stored with limited permissions (chmod 600)
- Passwords are masked in the terminal UI
- Connection strings with passwords are never displayed in plaintext
- Be mindful that connection details are stored in configuration files in your environment
Flox combines package and environment management, building on Nix. It gives you Nix with a git-like syntax and an intuitive UX:
- Declarative environments. Software packages, variables, services, etc. are defined in simple, human-readable TOML format;
- Content-addressed storage. Multiple versions of packages with conflicting dependencies can coexist in the same environment;
- Reproducibility. The same environment can be reused across development, CI, and production;
- Deterministic builds. The same inputs always produce identical outputs for a given architecture, regardless of when or where builds occur;
- World's largest collection of packages. Access to over 150,000 packages—and millions of package-version combinations—from Nixpkgs.