-
Notifications
You must be signed in to change notification settings - Fork 0
/
devenv.nix
152 lines (130 loc) · 3.45 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
{
pkgs,
lib,
config,
inputs,
...
}:
let
python-packages =
p: with p; [
pip
python-lsp-server
epc
pylint
];
compose-path = "./tests/docker-compose.yml";
in
{
name = "sparkle";
# https://devenv.sh/basics/
env = {
GREET = "🛠️ Let's hack ";
};
scripts = {
hello.exec = "echo $GREET";
cat.exec = "bat $@";
release = {
# This script is temporary due to two problems:
# 1. `cz` requires a personal github token to publish a release https://commitizen-tools.github.io/commitizen/tutorials/github_actions/
# 2. `cz bump` fails to sign in a terminal: https://github.com/commitizen-tools/commitizen/issues/1184
exec = ''
rm CHANGELOG.md
cz bump --files-only --check-consistency
git tag $(python -c "from src.sparkle import __version__; print(__version__)")
'';
description = ''
Release a new version and update the CHANGELOG.
'';
};
up = {
exec = "devenv up -d";
description = "Start processes in the background.";
};
down = {
exec = "devenv processes down";
description = "Stop processes.";
};
cleanup = {
exec = "docker compose -f ${compose-path} rm -vf";
description = "Remove unused docker containers and volumes.";
};
pyfix = {
exec = "ruff check . --fix && ruff format .";
description = "Lint, (possibly) fix and apply formatting to python files.";
};
show = {
exec = ''
GREEN="\033[0;32m";
YELLOW="\033[33m";
NC="\033[0m";
echo
echo -e "✨ Helper scripts you can run to make your development richer:"
echo
${pkgs.gnused}/bin/sed -e 's| |••|g' -e 's|=| |' <<EOF | ${pkgs.util-linuxMinimal}/bin/column -t | ${pkgs.gnused}/bin/sed -e "s|^\([^ ]*\)|$(printf "$GREEN")\1$(printf "$NC"): |" -e "s|^|$(printf "$YELLOW*$NC") |" -e 's|••| |g'
${lib.generators.toKeyValue { } (
lib.mapAttrs (name: value: value.description) (
lib.filterAttrs (_: value: value.description != "") config.scripts
)
)}
EOF
echo
'';
description = "Print this message and exit.";
};
};
# https://devenv.sh/packages/
packages = with pkgs; [
nixfmt-rfc-style
bat
jq
tealdeer
docker
docker-compose
# Python Dependencies
(python3.withPackages python-packages)
];
languages = {
python = {
enable = true;
version = "3.10.14";
poetry = {
enable = true;
activate.enable = true;
install.enable = true;
install.allExtras = true;
install.groups = [ "dev" ];
};
};
};
languages.java.enable = true;
languages.java.jdk.package = pkgs.jdk8; # Java version running on AWS Glue
processes = {
kafka-test.exec = ''
docker compose -f ${compose-path} up --build
'';
};
enterShell = ''
hello
show
'';
# https://devenv.sh/pre-commit-hooks/
pre-commit.hooks = {
nixfmt-rfc-style = {
enable = true;
excludes = [ ".devenv.flake.nix" ];
};
yamllint = {
enable = true;
settings.preset = "relaxed";
};
ruff.enable = true;
editorconfig-checker.enable = true;
};
# Make diffs fantastic
difftastic.enable = true;
# https://devenv.sh/integrations/dotenv/
dotenv.enable = true;
# https://devenv.sh/integrations/codespaces-devcontainer/
devcontainer.enable = true;
}