-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathflake.nix
More file actions
77 lines (65 loc) · 1.93 KB
/
flake.nix
File metadata and controls
77 lines (65 loc) · 1.93 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
{
description = "A reproducible environment for textX-LS development";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
# Python development environment
pythonEnv = pkgs.python312.withPackages (ps: with ps; [
pip
black
bandit
coverage
flake8
mock
flit
pytest
pytest-cov
python-lsp-server
debugpy
]);
deps = with pkgs; [
vscode
nodejs
vsce
typescript
vscode-with-extensions
pre-commit
ruff
];
in {
devShells.default = pkgs.mkShell {
packages = [ pythonEnv ] ++ deps;
VIRTUAL_ENV = "./venv";
shellHook = ''
echo "Python environment env: ${pythonEnv}"
echo "Node.js version: $(node --version)"
# Create .env file if it doesn't exist
if [ ! -f .env ]; then
echo "PYTHONPATH=$PWD" > .env
echo "Creating .env file with PYTHONPATH"
fi
# Create virtualenv if it doesn't exist
if [ ! -d "$VIRTUAL_ENV" ]; then
echo "=== Creating Python virtual env and installing deps ==="
python -m venv "$VIRTUAL_ENV"
# Activate the virtualenv
source "$VIRTUAL_ENV/bin/activate"
pip install --upgrade pip
pip install -r requirements.txt
else
# Activate the virtualenv
source "$VIRTUAL_ENV/bin/activate"
fi
echo "Ready for the development!"
'';
};
});
}