-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
141 lines (128 loc) · 3.5 KB
/
default.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
{ sources ? import ./nix/sources.nix
, system ? builtins.currentSystem
, pkgs ? import sources.nixpkgs { inherit system; }
, python ? "python310"
, ...
}:
let
## Our base Python:
thisPython = pkgs.${python}.override {
packageOverrides = pself: psuper: {
flake8-comprehensions = pself.buildPythonPackage rec {
pname = "flake8_comprehensions";
version = "3.12.0";
format = "wheel";
src = pself.fetchPypi {
inherit pname version format;
dist = "py3";
python = "py3";
sha256 = "sha256-ATI0Y37H38t80pAFePtTxRL4HbkJzv43HAGSMmlcNi0=";
};
propagatedBuildInputs = [
pself.flake8
];
};
flake8-print = pself.buildPythonPackage rec {
pname = "flake8_print";
version = "5.0.0";
format = "wheel";
src = pself.fetchPypi {
inherit pname version format;
dist = "py3";
python = "py3";
sha256 = "sha256-hKGm6hDXBWuAQiGsXmKxzuGu/Il84W8uXELTBGBo9dg=";
};
propagatedBuildInputs = [
pself.flake8
pself.pycodestyle
];
};
flake8-pyproject = pself.buildPythonPackage rec {
pname = "flake8_pyproject";
version = "1.2.3";
format = "wheel";
src = pself.fetchPypi {
inherit pname version format;
python = "py3";
sha256 = "sha256-Ykn+U1RSBa9edoN2RNyAtMEAN+c6Dl24f/Vi11+1vUo=";
};
propagatedBuildInputs = [
pself.flake8
pself.tomli
];
};
flake8-type-checking = pself.buildPythonPackage rec {
pname = "flake8_type_checking";
version = "2.4.0";
format = "wheel";
src = pself.fetchPypi {
inherit pname version format;
dist = "py3";
python = "py3";
sha256 = "sha256-Le4SfzALuVt/F7fD//T2M29eS6kggsFZKMbhm2Zs+6Q=";
};
propagatedBuildInputs = [
pself.astor
pself.classify-imports
pself.flake8
];
};
};
};
## Our project definition:
thisProject = (builtins.fromTOML (builtins.readFile ./pyproject.toml)).project;
## Our package:
thisPackage = thisPython.pkgs.buildPythonPackage {
pname = thisProject.name;
version = thisProject.version;
format = "pyproject";
src = ./.;
propagatedBuildInputs = [
thisPython.pkgs.python-dateutil
];
};
## Our Python with production and development packages:
thisPythonWithDeps = thisPython.withPackages (ps: with ps;
thisPackage.propagatedBuildInputs ++ [
## Development tools:
ps.black
ps.build
ps.flake8
ps.flake8-bugbear
ps.flake8-comprehensions
ps.flake8-docstrings
ps.flake8-print
ps.flake8-pyproject
ps.flake8-type-checking
ps.ipython
ps.isort
ps.mypy
ps.nox
ps.pip
ps.pylint
ps.pytest
ps.pytest-cov
ps.sphinx
ps.sphinx-rtd-theme
ps.sphinxcontrib-apidoc
ps.twine
ps.wheel
## Types:
ps.types-python-dateutil
]
);
## Our Nix shell:
thisShell = pkgs.mkShell {
packages = [
## Python dependency with packages for development purposes:
thisPythonWithDeps
## Further development dependencies:
pkgs.nodePackages.pyright
];
shellHook = ''
## Make sure that we emulate Python development (or editable) mode:
pip install -e . --prefix $TMPDIR/
'';
};
in
if pkgs.lib.inNixShell then thisShell else thisPackage