-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevenv.nix
71 lines (63 loc) · 1.61 KB
/
devenv.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
69
70
71
{ pkgs, ... }:
{
languages = {
nix = {
enable = true;
};
elixir = {
enable = true;
package = pkgs.beam.packages.erlangR25.elixir;
};
};
packages = [
pkgs.elixir-ls
pkgs.inotify-tools
];
scripts.check.exec = ''
echo "📋 Checking formatting..."
mix format --check-formatted
format_result=$?
echo "🧪 Running tests..."
mix test
test_result=$?
exit $((format_result + test_result))
'';
scripts.run.exec = ''
while [[ $# -gt 0 ]]; do
case $1 in
-i|--interactive)
interactive=yes
shift
;;
esac
done
if [[ $interactive == yes ]]; then
iex -S mix phx.server
else
mix phx.server
fi
'';
scripts.setup.exec = "mix setup";
enterShell = ''
green='\033[0;32m'
reset_color='\033[0m'
echo "🐞 Welcome to Humbug 🐞"
echo ""
echo "Useful commands:"
echo -e " ► ''${green}setup''${reset_color}: Fetch all dependencies."
echo -e " ► ''${green}check''${reset_color}: Run format check and tests."
echo -e " ► ''${green}run''${reset_color}: Start the server, use -i/--interactive to start it in an interative repl."
echo -e " Start the database with ''${green}devenv up''${reset_color} or ''${green}start-postgres''${reset_color} first."
echo ""
'';
services = {
postgres = {
enable = true;
initialDatabases = [{ name = "humbug_dev"; }];
initialScript = ''
CREATE USER postgres WITH PASSWORD 'postgres' CREATEDB;
ALTER DATABASE humbug_dev OWNER TO postgres;
'';
};
};
}