first map setup
This commit is contained in:
71
shell.nix
Normal file
71
shell.nix
Normal file
@@ -0,0 +1,71 @@
|
||||
# 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
|
||||
];
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user