-
Notifications
You must be signed in to change notification settings - Fork 2
/
devenv.nix
158 lines (152 loc) · 3.78 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
{ pkgs, lib, ... }:
{
packages =
[
pkgs.cargo-binstall
pkgs.cargo-run-bin
pkgs.coreutils
pkgs.dprint
pkgs.libiconv
pkgs.nixfmt-rfc-style
pkgs.rustup
pkgs.shfmt
]
++ lib.optionals pkgs.stdenv.isDarwin (
with pkgs.darwin.apple_sdk;
[
frameworks.CoreFoundation
frameworks.Security
frameworks.System
frameworks.SystemConfiguration
]
);
scripts."install:all" = {
exec = ''
set -e
cargo bin --install
'';
description = "Install all packages.";
};
scripts."update:deps" = {
exec = ''
set -e
cargo update
devenv update
'';
description = "Update dependencies.";
};
scripts."build:all" = {
exec = ''
set -e
if [ -z "$CI" ]; then
echo "Builing project locally"
cargo build
cargo build --all-features
else
echo "Building in CI"
cargo build --locked
cargo build --all-features --locked
fi
'';
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
'';
description = "Fix all fixable issues";
};
scripts."fix:format" = {
exec = ''
set -e
dprint fmt
'';
description = "Format the files with dprint";
};
scripts."fix:clippy" = {
exec = ''
set -e
cargo clippy --fix --allow-dirty --allow-staged --all-features
'';
description = "Fix all clippy issues";
};
scripts."lint:all" = {
exec = ''
set -e
lint:format
lint:clippy
'';
description = "Lint the whole codebase and fail if any issues found.";
};
scripts."lint:format" = {
exec = ''
set -e
dprint check
'';
description = "Check that formatting is correct for the project.";
};
scripts."lint:clippy" = {
exec = ''
set -e
cargo clippy
cargo check --all-features
'';
description = "Check that lint rules are maintained for the entire project";
};
scripts."snapshot:update" = {
exec = ''
INSTA_UPDATE=always INSTA_FORCE_PASS=1 test:all
'';
description = "Update all snapshots when running the test suite.";
};
scripts."test:all" = {
exec = ''
set -e
cargo test_default
cargo test_all
cargo test_docs_default
cargo test_docs_all
'';
description = "Run all tests for the project.";
};
scripts."coverage:all" = {
exec = ''
set -e
cargo coverage_default
cargo coverage_all
cargo coverage_docs_default
cargo coverage_docs_all
cargo coverage_codecov_report
'';
description = "Generate a coverage report for the project";
};
scripts."setup:ci" = {
exec = ''
set -e
# update GitHub CI Path
echo "$DEVENV_PROFILE/bin" >> $GITHUB_PATH
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 = "";
};
}