73 lines
1.7 KiB
Nix
73 lines
1.7 KiB
Nix
# shell.nix
|
|
/*
|
|
# Dev env for elixir
|
|
|
|
|
|
## Environment Variables
|
|
|
|
- MIX_HOME: Local Mix installation
|
|
- HEX_HOME: Local Hex package manager
|
|
- PGDIR: PostgreSQL data directory
|
|
- PGHOST: Unix domain socket location
|
|
- DATABASE_URL: PostgreSQL connection string
|
|
*/
|
|
|
|
let
|
|
# Import nixos-unstable for most packages
|
|
pkgs = import <nixpkgs> {};
|
|
# Import nixpkgs-unstable for outliers
|
|
pkgs-unstable = import <nixpkgs-unstable> {};
|
|
|
|
extraPackages = [
|
|
pkgs.beam.packages.erlang_27.elixir_1_18
|
|
pkgs.beam.packages.erlang_27.erlang
|
|
pkgs.elixir_ls
|
|
pkgs.inotify-tools
|
|
|
|
# DB
|
|
pkgs.postgresql
|
|
# JS
|
|
pkgs-unstable.deno
|
|
# PY
|
|
pkgs.python3
|
|
pkgs.python3Packages.laspy
|
|
pkgs.python3Packages.scipy
|
|
pkgs.python3Packages.numpy
|
|
pkgs.python3Packages.pyproj
|
|
pkgs.python3Packages.requests
|
|
];
|
|
|
|
mkShell = pkgs.mkShell;
|
|
PROJECT_ROOT = builtins.toString ./.;
|
|
|
|
hooks = ''
|
|
# Set up environment variables
|
|
|
|
# PostgreSQL configuration
|
|
export PGDIR=${PROJECT_ROOT}/postgres
|
|
export PGHOST=$PGDIR
|
|
export PGDATA=$PGDIR/data
|
|
export PGLOG=$PGDIR/log
|
|
export DATABASE_URL="postgresql:///postgres?host=$PGDIR"
|
|
|
|
# Create PostgreSQL directories if they don't exist
|
|
if test ! -d $PGDIR; then
|
|
mkdir $PGDIR
|
|
fi
|
|
|
|
if [ ! -d $PGDATA ]; then
|
|
echo 'Initializing postgresql database...'
|
|
initdb $PGDATA --auth=trust >/dev/null
|
|
fi
|
|
|
|
# Print setup instructions
|
|
echo "Elixir development environment ready!"
|
|
echo "To start PostgreSQL, run: postgres -h \'\' -k \'$PGHOST\'"
|
|
echo "To start the project, run : iex -S mix phx.server"
|
|
'';
|
|
|
|
in mkShell {
|
|
buildInputs = extraPackages;
|
|
shellHook = hooks;
|
|
}
|