forked from ERGO-Code/HiGHS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
73 lines (69 loc) · 1.94 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
{
inputs = {
nixpkgs = {
url = "github:nixos/nixpkgs/nixos-unstable";
};
flake-utils = {
url = "github:numtide/flake-utils";
};
};
outputs = { nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
version = with pkgs.lib;
# Read the version. Note: We assume the version numbers are in
# order in the file; i.e. Major, Minor, Patch.
let f = builtins.readFile ./Version.txt;
l = strings.splitString "\n" f;
# Drop the last term; it just says if it's alpha or not.
t = lists.take 3 l;
# Get the numbers on the other side of the equals
vs = lists.forEach t (v: lists.drop 1 (strings.splitString "=" v));
# That's it!
in concatStrings (intersperse "." (lists.flatten vs));
# Build the binary
highs-binary = with pkgs; stdenv.mkDerivation {
pname = "highs";
inherit version;
src = pkgs.lib.cleanSource ./.;
nativeBuildInputs = [
clang
cmake
];
};
# Build the python package
highspy = pkgs.python3Packages.buildPythonPackage {
inherit version;
pname = "highspy";
src = pkgs.lib.cleanSource ./.;
format = "pyproject";
dontUseCmakeConfigure = true;
nativeBuildInputs = with pkgs.python3Packages; [
numpy
pathspec
pybind11
pyproject-metadata
scikit-build-core
pkgs.cmake
pkgs.ninja
];
buildInputs = [
pkgs.zlib
];
};
in rec {
defaultApp = flake-utils.lib.mkApp {
drv = highs-binary;
};
defaultPackage = highs-binary;
packages.highspy = highspy;
devShells.highspy = pkgs.mkShell {
buildInputs = [
(pkgs.python3.withPackages (ps: [ highspy ]) )
];
};
}
);
}