forked from alertot/cpematcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devenv.nix
72 lines (65 loc) · 1.6 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
{ pkgs, lib, config, inputs, ... }:
let
root-dir = config.devenv.root;
default-python-version = "3.11";
in
{
# https://devenv.sh/basics/
env = {
# These are defined in languages.python, we need to override them
POETRY_VIRTUALENVS_IN_PROJECT = lib.mkForce "false";
POETRY_VIRTUALENVS_PATH = lib.mkForce "${root-dir}/.venvs";
POETRY_VIRTUALENVS_PREFER_ACTIVE_PYTHON = lib.mkForce "true";
};
# https://devenv.sh/packages/
packages = with pkgs; [
git
just
(buildEnv {
name = "python";
paths = [
inputs.nixpkgs-python.packages.x86_64-linux."3.8"
python39
python310
python311
python312
python313
];
ignoreCollisions = true;
})
];
# https://devenv.sh/languages/
# https://devenv.sh/scripts/
scripts.run-python-version.exec = ''
#!/usr/bin/env bash
VERSION=$1
shift
COMMAND="$@"
poetry env use $VERSION
poetry run -- $COMMAND
'';
enterShell = ''
poetry env use ${default-python-version}
export PATH=$(poetry env info -p)/bin:$PATH
'';
# https://devenv.sh/tests/
enterTest = ''
echo "Running tests"
python -m pytest tests/
'';
# https://devenv.sh/pre-commit-hooks/
pre-commit.hooks = {
ruff = {
enable = true;
args = [ "--config" "${root-dir}/pyproject.toml" ];
};
ruff-format.enable = true;
check-added-large-files.enable = true;
trim-trailing-whitespace = {
enable = true;
excludes = [ ".*.md$" ];
};
end-of-file-fixer.enable = true;
};
# See full reference at https://devenv.sh/reference/options/
}