This repository has been archived by the owner on Feb 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
shell.nix
68 lines (56 loc) · 1.59 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
60
61
62
63
64
65
66
67
68
let pkgs = import <nixpkgs> {};
version="1.0.dev0";
base = import ./base.nix {inherit version pkgs;};
in base.overrideAttrs (self: rec {
buildInputs = self.buildInputs ++ [
pkgs.yarn
pkgs.postgresql_12
];
exportVarsHook=''
export DJANGO_SETTINGS_MODULE=zoo.base.settings
export ZOO_DEBUG=true
'';
yarnHook = ''
function process_assets {
say "Running yarn && webpack"
cd $PROJ_HOME/webpack
yarn install
if [ -d source ]; then
rm -rf source
fi
cp -r $PROJ_HOME/zoo source
yarn production
cd $PROJ_HOME
say "Running django-admin collectstatic"
django-admin collectstatic --noinput > /dev/null
}
say "To process js/css assets please execute shellc command process_assets !"
'';
databaseHook = ''
export PGBASE=$PWD/.postgres
export PGDATA=$PGBASE/data
export PGSOCKET=$PGBASE/socket
export LOG_PATH=$PGBASE/LOG
export PGDATABASE=postgres
export DATABASE_URL="postgres://localhost/postgres"
export TEST_DATABASE_URL="postgres://localhost/postgres"
if [ ! -d $PGBASE ]; then
mkdir $PGBASE
fi
if [ ! -d $PGSOCKET ]; then
mkdir $PGSOCKET
fi
if [ ! -d $PGDATA ]; then
say "Initializing postgresql databse"
initdb --auth=trust --no-locale --encoding=UTF8 > /dev/null
fi
say_green "Starting postgres database"
pg_ctl start -l $LOG_PATH -D $PGDATA -o "-c unix_socket_directories=$PGSOCKET"
trap "pg_ctl stop" EXIT
'';
shellHook=self.shellHook + ''
${exportVarsHook}
${yarnHook}
${databaseHook}
'';
})