-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
107 lines (105 loc) · 3.14 KB
/
flake.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
{
description = "parsemon2";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
let
supportedSystems = [
"aarch64-linux"
# pyopenssl is broken
# "aarch64-darwin"
"i686-linux"
"x86_64-darwin"
"x86_64-linux"
];
systemDependent = flake-utils.lib.eachSystem supportedSystems (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
python = pkgs.python3;
runCodeAnalysis = name: command:
pkgs.runCommand "${name}-parsemon2" { } ''
cd ${self}
${command}
mkdir $out
'';
in
{
formatter = pkgs.nixpkgs-fmt;
devShells.default = pkgs.mkShell {
buildInputs = [
(python.withPackages (ps:
with ps; [
black
flake8
hypothesis
isort
mypy
pip
pytest-benchmark
pytest-profiling
pytestcov
setuptools-rust
sphinx
virtualenv
wheel
twine
]))
pkgs.rustc
pkgs.rustfmt
pkgs.cargo
pkgs.git
pkgs.graphviz
python.pkgs.gprof2dot
];
};
packages = {
inherit python;
default = python.pkgs.parsemon2;
};
checks = {
python39 = pkgs.python39.pkgs.parsemon2;
python310 = pkgs.python310.pkgs.parsemon2;
python311 = pkgs.python311.pkgs.parsemon2;
black-check = runCodeAnalysis "black" ''
${python.pkgs.black}/bin/black --check .
'';
mypy-check = runCodeAnalysis "mypy" ''
${python.pkgs.mypy}/bin/mypy src/parsemon
'';
isort-check = runCodeAnalysis "isort" ''
${python.pkgs.isort}/bin/isort \
--settings-path setup.cfg \
--check-only \
--diff \
setup.py \
. \
test-pypi-install
'';
flake8-check = runCodeAnalysis "flake8" ''
${python.pkgs.flake8}/bin/flake8
'';
rustfmt-check = runCodeAnalysis "rustfmt" ''
${pkgs.rustfmt}/bin/rustfmt \
--check \
$(find src/ -type f -name '*.rs')
'';
};
});
systemIndependent = {
lib = {
packageOverrides = import nix/package-overrides.nix;
package = import nix/parsemon2.nix;
};
overlays.default = final: prev: {
pythonPackagesExtensions =
prev.pythonPackagesExtensions ++ [ self.lib.packageOverrides ];
};
};
in
systemDependent // systemIndependent;
}