-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
108 lines (106 loc) · 3.43 KB
/
flake.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{
description = "ZOUT";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
devshell = {
url = "github:numtide/devshell";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
};
outputs = { self, nixpkgs, devshell, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; overlays = [ devshell.overlay ]; };
in
{
devShells = rec {
default = zout;
zout = pkgs.devshell.mkShell {
name = "ZOUT";
packages = [
pkgs.ffmpeg
pkgs.nixpkgs-fmt
pkgs.erlang
pkgs.elixir_1_14
(pkgs.postgresql_14.withPackages (p: [ p.timescaledb ]))
pkgs.inotify-tools
pkgs.nodejs-16_x
pkgs.docker-compose
];
env = [
{
name = "PGDATA";
eval = "$PWD/tmp/postgres";
}
{
name = "DATABASE_HOST";
eval = "$PGDATA";
}
];
commands = [
{
name = "pg:setup";
category = "database";
help = "Setup postgres in project folder";
command = ''
initdb --encoding=UTF8 --no-locale --no-instructions -U postgres
echo "unix_socket_directories = '$PGDATA'" >> $PGDATA/postgresql.conf
echo "shared_preload_libraries = 'timescaledb'" >> $PGDATA/postgresql.conf
echo "CREATE USER postgres WITH PASSWORD 'postgres' CREATEDB;" | postgres --single -E postgres
echo "CREATE DATABASE zout_dev;" | postgres --single -E postgres
'';
}
{
name = "pg:start";
category = "database";
help = "Start postgres instance";
command = ''
[ ! -d $PGDATA ] && pg:setup
pg_ctl -D $PGDATA -U postgres start -l tmp/postgres.log
'';
}
{
name = "pg:stop";
category = "database";
help = "Stop postgres instance";
command = ''
pg_ctl -D $PGDATA -U postgres stop
'';
}
{
name = "pg:console";
category = "database";
help = "Open database console";
command = ''
psql --host $PGDATA -U postgres
'';
}
{
name = "link";
category = "editor";
help = "Create shortcuts for Intellij SDK";
command = ''
mkdir -p "$PWD/tmp/current"
ln -sfn ${pkgs.erlang} "$PWD/tmp/current/erlang"
ln -sfn ${pkgs.elixir} "$PWD/tmp/current/elixir"
'';
}
{
name = "idea";
category = "editor";
help = "Start Intellij Ultimate (system) in this project";
command = ''
link
idea-ultimate . >/dev/null 2>&1 &
'';
}
];
};
};
}
);
}