This repository was archived by the owner on Mar 4, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevenv.nix
More file actions
219 lines (189 loc) Β· 5.91 KB
/
devenv.nix
File metadata and controls
219 lines (189 loc) Β· 5.91 KB
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
{ pkgs, lib, config, inputs, ... }:
{
# Language configuration
languages.python = {
enable = true;
version = "3.11";
venv.enable = true;
venv.requirements = ''
# Core dependencies
click>=8.1.0
rich>=13.0.0
pyyaml>=6.0.1
jinja2>=3.1.2
# Development dependencies
pytest>=7.4.0
pytest-cov>=4.1.0
pytest-mock>=3.12.0
ruff>=0.1.0
mypy>=1.8.0
# Documentation dependencies
sphinx>=7.0.0
sphinx_rtd_theme>=2.0.0
'';
};
# System packages available in the shell
packages = with pkgs; [
# Python tooling
python312Packages.lizard # Complexity analysis (brownfield uses this)
# Git tooling
git
gh # GitHub CLI for PRs
# File utilities
fd # Fast find alternative
ripgrep # Fast grep
eza # Better ls
bat # Better cat
# Development utilities
jq # JSON processing
yq-go # YAML processing
];
# Environment variables
env = {
BROWNFIELD_DEBUG = "0";
PYTHONPATH = "${config.env.DEVENV_ROOT}/src";
};
# Scripts available in the shell
scripts = {
# Testing
test.exec = ''
pytest tests/ -v --tb=short
'';
test-cov.exec = ''
pytest tests/ --cov=src/brownfield --cov-report=html --cov-report=term
echo "π Coverage report generated: htmlcov/index.html"
'';
test-watch.exec = ''
pytest-watch tests/ -v
'';
# Code quality
lint.exec = ''
echo "π Running ruff check..."
ruff check src/ tests/
'';
lint-fix.exec = ''
echo "π§ Running ruff check with auto-fix..."
ruff check src/ tests/ --fix
'';
format.exec = ''
echo "β¨ Formatting code with ruff..."
ruff format src/ tests/
'';
typecheck.exec = ''
echo "π Running mypy type checker..."
mypy src/brownfield --ignore-missing-imports
'';
# Brownfield commands
assess-self.exec = ''
echo "π Running brownfield assess on itself..."
brownfield assess --quick
'';
status-self.exec = ''
brownfield status
'';
# Complexity analysis
complexity.exec = ''
echo "π Analyzing code complexity..."
lizard src/brownfield -l python --CCN 10
'';
# All quality checks
check-all.exec = ''
echo "π Running all quality checks..."
lint
format
typecheck
test
complexity
'';
# Build and install
install-dev.exec = ''
echo "π¦ Installing brownfield in editable mode..."
pip install -e .[dev]
echo "β
Brownfield installed! Run: brownfield --help"
'';
clean.exec = ''
echo "π§Ή Cleaning up build artifacts..."
rm -rf build/ dist/ *.egg-info .pytest_cache/ .ruff_cache/ htmlcov/ .coverage
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
echo "β
Cleaned!"
'';
};
# Git hooks (renamed from pre-commit in recent devenv versions)
git-hooks.hooks = {
# Python formatting and linting
ruff = {
enable = true;
name = "ruff";
entry = "${pkgs.ruff}/bin/ruff check --fix";
files = "\\.py$";
language = "system";
};
ruff-format = {
enable = true;
name = "ruff-format";
entry = "${pkgs.ruff}/bin/ruff format";
files = "\\.py$";
language = "system";
};
# Complexity gate
complexity-check = {
enable = true;
name = "complexity-check";
entry = "${pkgs.python312Packages.lizard}/bin/lizard -l python --CCN 10";
files = "\\.py$";
language = "system";
pass_filenames = true;
};
};
# Shell hook - runs when entering the shell
enterShell = ''
# Banner
echo ""
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo "β β"
echo "β π― BrownKit Development Environment β"
echo "β β"
echo "β AI-driven workflow for brownfield β Speckit ready β"
echo "β β"
echo "ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
echo ""
# Auto-install in editable mode
if [ ! -f ".devenv-initialized" ]; then
echo "π§ First-time setup: Installing brownfield in editable mode..."
pip install -e .[dev] --quiet
touch .devenv-initialized
echo "β
Setup complete!"
echo ""
fi
# Show helpful commands
echo "π Available Commands:"
echo " test - Run test suite"
echo " test-cov - Run tests with coverage report"
echo " lint - Run ruff linter"
echo " lint-fix - Auto-fix linting issues"
echo " format - Format code with ruff"
echo " typecheck - Run mypy type checker"
echo " complexity - Analyze code complexity"
echo " check-all - Run all quality checks"
echo " assess-self - Run brownfield assess on itself"
echo " clean - Clean build artifacts"
echo ""
echo "π Quick Start:"
echo " brownfield --help # Show CLI help"
echo " brownfield assess --help # Granular command"
echo " brownfield brownfield.assess # Workflow command"
echo ""
# Check git status
if [ -d .git ]; then
current_branch=$(git branch --show-current 2>/dev/null)
if [ -n "$current_branch" ]; then
echo "π Current branch: $current_branch"
fi
fi
echo ""
'';
# Process managers (optional, for running background services if needed)
# processes = {
# # Example: Could run a test watcher
# };
}