-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell.nix
executable file
·59 lines (55 loc) · 1.42 KB
/
shell.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env nix-shell
with import <nixpkgs> {};
let
# define packages to install with special handling for OSX
basePackages = [
gnumake
gcc
readline
openssl
zlib
libxml2
curl
libiconv
elixir_1_9
glibcLocales
nodejs-12_x
yarn
postgresql
];
inputs = basePackages
++ lib.optional stdenv.isLinux inotify-tools
++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
CoreFoundation
CoreServices
]);
# define shell startup command
hooks = ''
# this allows mix to work on the local directory
mkdir -p .nix-mix
mkdir -p .nix-hex
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"
export PGDATA="$PWD/db"
export SOCKET_DIRECTORIES="$PWD/sockets"
mkdir $SOCKET_DIRECTORIES
initdb
echo "unix_socket_directories = '$SOCKET_DIRECTORIES'" >> $PGDATA/postgresql.conf
pg_ctl -l $PGDATA/logfile start
createuser postgres --createdb -h localhost
function end {
echo "Shutting down the database..."
pg_ctl stop
echo "Removing directories..."
rm -rf $PGDATA $SOCKET_DIRECTORIES
}
trap end EXIT
'';
in mkShell {
buildInputs = inputs;
shellHook = hooks;
}