-
Notifications
You must be signed in to change notification settings - Fork 25
/
devenv.nix
126 lines (105 loc) · 2.83 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
{ inputs, pkgs, ... }:
{
devcontainer.enable = true;
difftastic.enable = true;
dotenv.enable = true;
languages = {
python = {
enable = true;
};
go.enable = true;
go.package = pkgs.go_1_21;
nix.enable = true;
c.enable = true;
cplusplus.enable = true;
rust = {
enable = true;
targets = [
"wasm32-unknown-unknown"
];
# https://devenv.sh/reference/options/#languagesrustchannel
channel = "stable";
components = [
"rustc"
"cargo"
"clippy"
"rustfmt"
"rust-src"
];
};
};
env.LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ];
# https://devenv.sh/packages/
packages = with pkgs; [
git
openssl
rust-analyzer
ninja
protobuf
just
# bun without bugs
(inputs.nixpkgs-working-bun.legacyPackages.${system}.bun)
];
enterShell = ''
echo "Welcome to devshell! Printing info.."
devenv info
echo "Printing legacy just commands.."
just
'';
# https://devenv.sh/tests/
enterTest = ''
echo "Running tests"
# Near localnet
wait_for_port 5888
# Sidecar
wait_for_port 3030
test-rust
test-eth
'';
# https://devenv.sh/pre-commit-hooks/
pre-commit.hooks = {
# execute example shell from Markdown files
mdsh.enable = true;
# format Python code
black.enable = true;
# shellcheck.enable = true;
check-json.enable = true;
check-toml.enable = true;
check-yaml.enable = true;
clippy.enable = true;
detect-private-keys.enable = true;
flake-checker.enable = true;
gofmt.enable = true;
# FIXME: Doesnt work because we setup sidecar etc gotest.enable = true;
rustfmt.enable = true;
cargo-check.enable = true;
};
# https://devenv.sh/services/
# services.postgres.enable = true;
# https://devenv.sh/processes/
scripts = {
# The sidecar used to interact with a live network
sidecar.exec = "RUST_LOG=debug cargo run --bin near-da-sidecar -- -c http-config.json";
# Test rust workspace
test-rust.exec = "cargo test --workspace --all-features";
# Test near da contract on eth
test-eth.exec = ''
cd eth
bun install
bun run lint
forge build --sizes
forge config
forge test --gas-report
'';
# Generate a changelog
changelog.exec = "git-cliff > CHANGELOG.md";
# Enrich JSON file with environment variable values
enrich.exec = ''scripts/enrich.sh http-config.template.json http-config.json'';
};
processes = {
set-key.exec = "docker compose up near-localnet-set-key";
localnet.exec = "docker compose up --build near-localnet";
sidecar.exec = "RUST_LOG=debug cargo run --bin near-da-sidecar -- -c test/http-sidecar.json";
};
# See full reference at https://devenv.sh/reference/options/
}