-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
74 lines (73 loc) · 2.37 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
{
inputs = {
flake-utils = {
url = "github:numtide/flake-utils";
};
nixpkgs = {
url = "github:NixOS/nixpkgs";
};
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs = {
nixpkgs = {
follows = "nixpkgs";
};
};
};
};
outputs = { self, nixpkgs, flake-utils, poetry2nix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
p2n = poetry2nix.legacyPackages.${system};
pyproject = builtins.fromTOML(builtins.readFile(./pyproject.toml));
name = pyproject.tool.poetry.name;
default-python = pkgs.python310;
# Alternative Pythons for Tox
alternative-pythons = [
pkgs.python38
pkgs.python39
pkgs.python310
];
dev-dependencies = [
pkgs.poetry
];
pypkgs-build-requirements = {
charmonium-cache = [ "poetry" ];
charmonium-time-block = [ "poetry" ];
charmonium-async-subprocess = [ "poetry" ];
charmonium-freeze = [ "poetry" ];
tox = [ "hatchling" "hatch-vcs" ];
bump2version = [ "setuptools" ];
gitchangelog = [ "setuptools" "d2to1" ];
mando = [ "setuptools" ];
proselint = [ "poetry" ];
deptry = [ "poetry" ];
pyproject-api = [ "hatchling" "hatch-vcs" ];
pyprojroot = [ "setuptools" ];
autoimport = [ "setuptools" ];
radon = [ "setuptools" ];
pytest-assume = [ "setuptools" ];
};
p2n-overrides = p2n.defaultPoetryOverrides.extend (self: super:
builtins.mapAttrs (package: build-requirements:
(builtins.getAttr package super).overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ (builtins.map (pkg: if builtins.isString pkg then builtins.getAttr pkg super else pkg) build-requirements);
})
) pypkgs-build-requirements
);
in {
devShells = rec {
default = pkgs.mkShell {
packages = [
(p2n.mkPoetryEnv {
projectDir = ./.;
python = default-python;
groups = [ "dev" ];
overrides = p2n-overrides;
})
] ++ dev-dependencies ++ alternative-pythons;
};
};
});
}