-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
93 lines (83 loc) · 2.98 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
futils.url = "github:numtide/flake-utils";
poetry2nix.url = "github:nix-community/poetry2nix";
};
outputs = { self, nixpkgs, futils, poetry2nix } @ inputs:
let
inherit (nixpkgs) lib;
inherit (lib) recursiveUpdate;
inherit (futils.lib) eachDefaultSystem defaultSystems;
nixpkgsFor = lib.genAttrs defaultSystems (system: import nixpkgs {
inherit system;
overlays = [
poetry2nix.overlay
self.overlay
];
});
poetryArgs = { pkgs, groups ? [ ] }: {
projectDir = self;
src = self;
inherit groups;
overrides = pkgs.poetry2nix.overrides.withDefaults (self: super: {
dataconf = super.dataconf.overridePythonAttrs (old: {
buildInputs = old.buildInputs ++ [ self.poetry ];
});
pathspec = super.pathspec.overridePythonAttrs (old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.flit-core ];
});
pies = super.pies.overridePythonAttrs (old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.setuptools ];
});
pydocstyle = super.pydocstyle.overridePythonAttrs (old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.poetry ];
});
pyproject-hooks = super.pyproject-hooks.overridePythonAttrs (old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [ self.flit-core ];
});
setoptconf-tmp = super.setoptconf-tmp.overridePythonAttrs (old: {
buildInputs = old.buildInputs ++ [ self.setuptools ];
});
});
meta = with lib; {
inherit (self) description;
maintainers = with maintainers; [ risson ];
};
};
anySystemOutputs = {
overlay = final: prev: {
afs-tools = final.poetry2nix.mkPoetryApplication (poetryArgs { pkgs = final; });
};
};
multipleSystemsOutputs = eachDefaultSystem (system:
let
pkgs = nixpkgsFor.${system};
in
{
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
git
poetry
((pkgs.poetry2nix.mkPoetryEnv (removeAttrs (poetryArgs { inherit pkgs; groups = [ "dev" ]; }) [ "meta" "src" "propagatedBuildInputs" ])).override { ignoreCollisions = true; })
];
PYTHONPATH = ".";
};
packages = {
inherit (pkgs) afs-tools;
default = pkgs.afs-tools;
};
apps = {
afs-tools = {
type = "app";
program = "${self.packages.${system}.afs-tools}/bin/afs-tools";
};
default = {
type = "app";
program = "${self.packages.${system}.default}/bin/afs-tools";
};
};
});
in
recursiveUpdate multipleSystemsOutputs anySystemOutputs;
}