Created
July 21, 2021 20:18
-
-
Save thalesmg/16c29861dc5f164e67578caa6fa9ec8b to your computer and use it in GitHub Desktop.
elixir 1.12 e erlang 24 phoenix derivation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import <nixpkgs> {} }: | |
with pkgs; | |
let | |
elixir_1_12 = { mkDerivation }: | |
mkDerivation rec { | |
version = "1.12.0"; | |
sha256 = "00dc3szjn2k552jp7n1c98kjab6wac9d49v2gr43pf3yzcyv8mk1"; | |
minimumOTPVersion = "24"; | |
}; | |
erlang = erlangR24; | |
elixir = beam.lib.callElixir elixir_1_12 { | |
inherit erlang; | |
debugInfo = true; | |
}; | |
in mkShell { | |
name = "magnet_dev"; | |
# define packages to install with special handling for OSX | |
buildInputs = [ | |
gnumake | |
gcc | |
readline | |
openssl | |
zlib | |
libxml2 | |
curl | |
libiconv | |
# my elixir derivation | |
elixir | |
glibcLocales | |
nodejs-12_x | |
yarn | |
postgresql | |
] ++ lib.optional stdenv.isLinux [ | |
inotify-tools | |
# observer gtk engine | |
gtk-engine-murrine | |
] | |
++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ | |
CoreFoundation | |
CoreServices | |
]); | |
# define shell startup command | |
shellHook = '' | |
# create local tmp folders | |
mkdir -p .nix-mix | |
mkdir -p .nix-hex | |
# elixir local PATH | |
# this allows mix to work on the local directory | |
export MIX_HOME=$PWD/.nix-mix | |
export HEX_HOME=$PWD/.nix-hex | |
export PATH=$MIX_HOME/bin:$PATH | |
export PATH=$HEX_HOME/bin:$PATH | |
export LANG=en_US.UTF-8 | |
export ERL_AFLAGS="-kernel shell_history enabled" | |
# to not conflict with your host elixir | |
# version and supress warnings about standard | |
# libraries | |
export ERL_LIBS=$HEX_HOME/lib/erlang/lib | |
# postgres PATH and bootstrap | |
export PGHOST=$PWD/.postgres | |
export PGDATA=$PGHOST/data | |
export PGLOG=$PGHOST/postgres.log | |
export PGPASSWORD=postgres | |
if [ ! -d $PGDATA ]; then | |
echo 'Initializing postgresql database...' | |
initdb --auth=trust --no-locale --encoding=UTF8 >/dev/null | |
fi | |
# start postgres server | |
pg_ctl start -l $PGLOG -o "--unix_socket_directories='$PGHOST'" | |
# check if thre's a postgres user or create it | |
psql -d postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname='postgres'" | grep -q 1 \ | |
|| createuser -s postgres | |
finish() { | |
pg_ctl -D $PGDATA stop | |
} | |
trap finish EXIT | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment