forked from yihuang/python-iavl
-
Notifications
You must be signed in to change notification settings - Fork 4
/
flake.nix
127 lines (125 loc) · 3.31 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-24.05";
flake-utils.url = "github:numtide/flake-utils";
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
poetry2nix,
}:
let
overrides =
{
lib,
poetry2nix,
rocksdb,
leveldb,
}:
poetry2nix.overrides.withDefaults (
lib.composeManyExtensions [
(
self: super:
let
buildSystems = {
rocksdb = [
"setuptools"
"cython"
"pkgconfig"
];
cprotobuf = [ "setuptools" ];
};
in
lib.mapAttrs (
attr: systems:
super.${attr}.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ map (a: self.${a}) systems;
})
) buildSystems
)
(self: super: {
rocksdb = super.rocksdb.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ rocksdb ];
});
plyvel = super.plyvel.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ leveldb ];
});
})
]
);
iavl-env =
{
poetry2nix,
callPackage,
groups ? [ "rocksdb" ],
}:
poetry2nix.mkPoetryEnv {
projectDir = ./.;
overrides = callPackage overrides { };
inherit groups;
};
iavl-cli =
{
poetry2nix,
callPackage,
groups ? [ "rocksdb" ],
}:
poetry2nix.mkPoetryApplication {
projectDir = ./.;
overrides = callPackage overrides { };
inherit groups;
};
in
(flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = self.overlays.default;
config = { };
};
in
rec {
packages = {
iavl-env = pkgs.callPackage iavl-env { };
iavl-env-leveldb = pkgs.callPackage iavl-env { groups = [ "leveldb" ]; };
iavl-cli = pkgs.callPackage iavl-cli { };
iavl-cli-leveldb = pkgs.callPackage iavl-cli { groups = [ "leveldb" ]; };
};
defaultPackage = packages.iavl-cli;
apps = {
default = {
type = "app";
program = "${packages.iavl-cli}/bin/iavl";
};
iavl-cli-leveldb = {
type = "app";
program = "${packages.iavl-cli-leveldb}/bin/iavl";
};
};
devShells = {
default = pkgs.mkShell {
buildInputs = [ packages.iavl-env ];
};
leveldb = pkgs.mkShell {
buildInputs = [ packages.iavl-env-leveldb ];
};
};
}
))
// {
overlays.default = [
poetry2nix.overlays.default
(final: prev: {
rocksdb = final.callPackage ./rocksdb.nix { };
})
];
};
}