-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
58 lines (53 loc) · 1.82 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
{
description = "Python environment for python-pfhub";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils}: (utils.lib.eachSystem ["x86_64-linux" ] (system:
let
pkgs = nixpkgs.legacyPackages.${system};
pypkgs = pkgs.python310Packages;
pypkgs-build-requirements = {
attrs = [ "hatchling" ];
urllib3 = [ "hatchling" ];
hbreader = [ "setuptools" ];
pytrie = [ "setuptools" ];
url-normalize = [ "poetry-core" ];
cfgraph = [ "setuptools" ];
pytest-logging = [ "setuptools" ];
mkdocs-windmill = [ "setuptools" ];
paginate = [ "setuptools" ];
};
p2n-overrides = pkgs.poetry2nix.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
);
args = {
projectDir = ./.;
preferWheels = true;
overrides = p2n-overrides;
};
env = pkgs.poetry2nix.mkPoetryEnv args;
app = pkgs.poetry2nix.mkPoetryApplication args;
in
rec {
## See https://github.com/nix-community/poetry2nix/issues/1433
## It seems like poetry2nix does not seem to install as dev
## environment
## devShells.default = env.env;
devShells.default = pkgs.mkShell {
packages = [ env ];
shellHook = ''
export PYTHONPATH=$PWD
'';
};
packages.pfhub = app;
packages.default = self.packages.${system}.pfhub;
}
)
);
}