Skip to content

Instantly share code, notes, and snippets.

@romannurik
Created April 2, 2024 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romannurik/78571a4cee33c41d246578fbc68ea3a2 to your computer and use it in GitHub Desktop.
Save romannurik/78571a4cee33c41d246578fbc68ea3a2 to your computer and use it in GitHub Desktop.
First attempt at postgres on IDX
# .idx/dev.nix
{ pkgs, ... }: {
# Which nixpkgs channel to use.
channel = "stable-23.11"; # or "unstable"
# Use https://search.nixos.org/packages to find packages
packages = [
pkgs.nodejs_18
# Packages for postgres.
# There may be an alternative approach using docker
pkgs.postgresql_16
pkgs.openssl
];
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
idx.extensions = [
"prisma.prisma"
"prisma.vscode-graphql"
];
services.docker.enable = true;
# Commands that run when a workspace first gets created
idx.workspace.onCreate = {
# When a workspace from this git repo gets created, init a local postgres
# (don't forget to .gitignore it)
# NOTE: you'll also need to point
pg-init = "initdb -D .postgres";
# Also run npm install to populate node_modules
# You probably also want to run `npx prisma generate` potentially...
npm-install = "npm install";
};
# Commands that run when the workspace is booted up
idx.workspace.onStart = {
# Start the postgres server
start-postgress = "pg_ctl -D .postgres start";
};
# Enable previews and customize configuration
idx.previews = {
enable = true;
previews = [
{
command = [ "npm" "run" "dev" ];
manager = "web";
id = "web";
env = {
PORT = "$PORT";
};
}
];
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment