This repository was archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevenv.nix
88 lines (75 loc) · 1.79 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
{
pkgs,
lib,
config,
inputs,
...
}:
{
# https://devenv.sh/basics/
env.GREET = "devenv";
env.DATABASE_URL = "postgres://postgres:postgres@localhost:5432/postgres";
# env.DBRUNNER_ADDR = "";
# env.FRONTEND_CORS_ORIGIN = "https://host1 https://host2";
# https://devenv.sh/packages/
packages =
[
pkgs.git
pkgs.sqlx-cli
pkgs.cargo-edit
pkgs.cargo-nextest
pkgs.protobuf
pkgs.sqlfluff
]
++ lib.optionals pkgs.stdenv.isDarwin (
with pkgs.darwin.apple_sdk; [ frameworks.SystemConfiguration ]
);
# https://devenv.sh/languages/
languages.rust.enable = true;
languages.rust.channel = "nightly";
# https://devenv.sh/processes/
processes.backend = {
exec = "cargo run --release";
process-compose = {
depends_on = {
postgres.condition = "process_healthy";
};
environment = [
"PORT=30000"
];
};
};
# https://devenv.sh/services/
services.postgres.enable = true;
services.postgres.listen_addresses = "127.0.0.1";
services.postgres.initialScript = ''
CREATE ROLE postgres SUPERUSER LOGIN PASSWORD 'postgres';
'';
# https://devenv.sh/scripts/
scripts.hello.exec = ''
echo hello from $GREET
'';
enterShell = ''
hello
git --version
'';
# https://devenv.sh/tests/
enterTest = ''
echo "Running tests"
git --version | grep --color=auto "${pkgs.git.version}"
'';
# https://devenv.sh/pre-commit-hooks/
pre-commit.hooks = {
shellcheck.enable = true;
rustfmt.enable = true;
clippy.enable = true;
sqlx-prepare = {
enable = true;
name = "Run sqlx prepare";
entry = "cargo sqlx prepare";
types = [ "rust" ];
pass_filenames = false;
};
};
# See full reference at https://devenv.sh/reference/options/
}