-
Notifications
You must be signed in to change notification settings - Fork 0
/
devenv.nix
193 lines (184 loc) · 4.71 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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
{ pkgs, lib, ... }:
{
packages =
[
pkgs.cargo-binstall
pkgs.cargo-run-bin
pkgs.dprint
pkgs.edgedb
pkgs.nixfmt-rfc-style
pkgs.rustup
pkgs.shfmt
]
++ lib.optionals pkgs.stdenv.isDarwin (
with pkgs.darwin.apple_sdk;
[
pkgs.libiconv
pkgs.coreutils
frameworks.Security
frameworks.System
]
);
# disable dotenv since it breaks the variable interpolation supported by `direnv`
dotenv.disableHint = true;
scripts."install:all" = {
exec = ''
set -e
install:cargo:bin
'';
description = "Install all dependencies.";
};
scripts."install:cargo:bin" = {
exec = ''
cargo bin --install
'';
description = "Install cargo binaries locally.";
};
scripts."db:destroy" = {
exec = ''
set -e
edgedb instance destroy -I $EDGEDB_INSTANCE --non-interactive --force
'';
description = "Destroy the local database.";
};
scripts."db:setup" = {
exec = ''
set -e
if [ ! -f "$DEVENV_ROOT/.env" ]; then
cp $DEVENV_ROOT/.env.example $DEVENV_ROOT/.env
export $(cat .env | xargs)
fi
edgedb instance create --non-interactive $EDGEDB_INSTANCE $EDGEDB_BRANCH || true
edgedb instance start --instance $EDGEDB_INSTANCE
edgedb migrate
'';
description = "Setup the local database.";
};
scripts."db:up" = {
exec = ''
set -e
edgedb watch --instance $EDGEDB_INSTANCE
'';
description = "Watch changes to the local database.";
};
scripts."update:deps" = {
exec = ''
set -e
cargo update
'';
description = "Update dependencies.";
};
scripts."build:all" = {
exec = ''
cargo build --all-features
'';
description = "Build all crates with all features activated.";
};
scripts."build:docs" = {
exec = ''
RUSTDOCFLAGS="--cfg docsrs" cargo doc --all-features
'';
description = "Build documentation site.";
};
scripts."fix:all" = {
exec = ''
set -e
fix:clippy
fix:format
cargo deny check
'';
description = "Fix all fixable lint issues.";
};
scripts."fix:format" = {
exec = ''
set -e
dprint fmt --config "$DEVENV_ROOT/dprint.json"
'';
description = "Fix formatting for entire project.";
};
scripts."fix:clippy" = {
exec = ''
set -e
cargo clippy --fix --allow-dirty --allow-staged --all-features
'';
description = "Fix fixable lint issues raised by rust clippy.";
};
scripts."lint:all" = {
exec = ''
set -e
lint:clippy
lint:format
cargo deny check
'';
description = "Lint all project files.";
};
scripts."lint:format" = {
exec = ''
set -e
dprint check
'';
description = "Check all formatting is correct.";
};
scripts."lint:clippy" = {
exec = ''
set -e
cargo clippy --all-features
'';
description = "Check rust clippy lints.";
};
scripts."test:all" = {
exec = ''
set -e
cargo test_codegen
cargo test_docs
'';
description = "Test all project files.";
};
scripts."coverage:all" = {
exec = ''
set -e
cargo coverage_codegen
cargo coverage_docs
cargo coverage_report
'';
description = "Test all files and generate a coverage report for upload to codecov.";
};
scripts."setup:vscode" = {
exec = ''
set -e
rm -rf .vscode
cp -r $DEVENV_ROOT/setup/editors/vscode .vscode
'';
description = "Setup the vscode editor for development.";
};
scripts."setup:helix" = {
exec = ''
set -e
rm -rf .helix
cp -r $DEVENV_ROOT/setup/editors/helix .helix
'';
description = "Setup the helix editor for development.";
};
scripts."setup:ci" = {
exec = ''
set -e
# update github ci path
echo "$DEVENV_PROFILE/bin" >> $GITHUB_PATH
# update github ci environment
echo "DEVENV_PROFILE=$DEVENV_PROFILE" >> $GITHUB_ENV
# prepend common compilation lookup paths
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo "LIBRARY_PATH=$LIBRARY_PATH" >> $GITHUB_ENV
echo "C_INCLUDE_PATH=$C_INCLUDE_PATH" >> $GITHUB_ENV
# these provide shell completions / default config options
echo "XDG_DATA_DIRS=$XDG_DATA_DIRS" >> $GITHUB_ENV
echo "XDG_CONFIG_DIRS=$XDG_CONFIG_DIRS" >> $GITHUB_ENV
echo "DEVENV_DOTFILE=$DEVENV_DOTFILE" >> $GITHUB_ENV
echo "DEVENV_PROFILE=$DEVENV_PROFILE" >> $GITHUB_ENV
echo "DEVENV_ROOT=$DEVENV_ROOT" >> $GITHUB_ENV
echo "DEVENV_STATE=$DEVENV_STATE" >> $GITHUB_ENV
'';
description = "Setup the github ci environment.";
};
}