-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathflake.nix
More file actions
133 lines (123 loc) · 3.71 KB
/
flake.nix
File metadata and controls
133 lines (123 loc) · 3.71 KB
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
128
129
130
131
132
133
{
description = "PyOperon development environment";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
foolnotion.url = "github:foolnotion/nur-pkg";
lbfgs.url = "github:foolnotion/lbfgs";
nixpkgs.url = "github:nixos/nixpkgs/master";
operon.url = "github:heal-research/operon";
pratt-parser.url = "github:foolnotion/pratt-parser-calculator";
vstat.url = "github:heal-research/vstat";
foolnotion.inputs.nixpkgs.follows = "nixpkgs";
lbfgs.inputs.nixpkgs.follows = "nixpkgs";
operon.inputs.nixpkgs.follows = "nixpkgs";
pratt-parser.inputs.nixpkgs.follows = "nixpkgs";
vstat.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
inputs@{
self,
flake-parts,
nixpkgs,
foolnotion,
pratt-parser,
lbfgs,
vstat,
operon,
}:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-darwin"
];
perSystem =
{ pkgs, system, ... }:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
foolnotion.overlay
(final: prev: {
vstat = vstat.packages.${system}.default;
})
];
};
enableShared = false;
stdenv_ = pkgs.llvmPackages_latest.stdenv;
python_ = pkgs.python3;
operon_ =
if enableShared then
operon.packages.${system}.library
else
operon.packages.${system}.library-static;
pyoperon = stdenv_.mkDerivation {
name = "pyoperon";
src = self;
cmakeFlags = [
"--preset ${if pkgs.stdenv.hostPlatform.isx86_64 then "build-linux" else "build-osx"}"
];
nativeBuildInputs = with pkgs; [
act
cmake
ninja
pkg-config
python_
python_.pkgs.pybind11
];
buildInputs =
with pkgs;
[
(python_.withPackages (
ps: with ps; [
setuptools
wheel
requests
nanobind
]
))
(operon_.overrideAttrs (old: {
cmakeFlags = old.cmakeFlags ++ [ "-DUSE_SINGLE_PRECISION=1" ];
}))
]
++ operon_.buildInputs;
};
in
rec {
packages = {
default = pyoperon;
pyoperon-generic = pyoperon.overrideAttrs (old: {
cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_CXX_FLAGS=${if pkgs.hostPlatform.isx86_64 then "-march=x86-64" else ""}"
];
});
pyoperon-debug = pyoperon.overrideAttrs (old: {
cmakeBuildType = "Debug";
});
};
devShells.default = stdenv_.mkDerivation {
name = "pyoperon-dev";
nativeBuildInputs = pyoperon.nativeBuildInputs;
buildInputs = pyoperon.buildInputs;
};
devShells.pyenv = stdenv_.mkDerivation {
name = "pyoperon-dev";
nativeBuildInputs = pyoperon.nativeBuildInputs;
buildInputs =
pyoperon.buildInputs
++ (with pkgs; [
pdm
virtualenv
zlib
])
++ (with python_.pkgs; [
numpy
pandas
scikit-learn
pytest
]);
LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib/:${pkgs.zlib}/lib/";
};
};
};
}