forked from aestream/aestream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
117 lines (114 loc) · 3.79 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
{
description = "Address Event Streaming library";
inputs = {
nixpkgs.url = "nixpkgs/nixos-22.11";
flake-utils.url = "github:numtide/flake-utils";
mach-nix.url = "mach-nix/3.5.0";
# mach-nix.pypiDataRev = "322a4f20c357704644abe8c2e50412e9b9c16909";
};
outputs = { self, nixpkgs, flake-utils, mach-nix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
py = pkgs.python310Packages;
libcaer = pkgs.stdenv.mkDerivation {
pname = "libcaer";
version = "3.3.14";
src = pkgs.fetchFromGitLab {
owner = "dv";
group = "inivation";
repo = "libcaer";
rev = "3.3.14";
hash = "sha1-ZszisfBWVLM7cXCGq7y1FeJ3RJA=";
};
nativeBuildInputs = with pkgs; [
pkg-config libusb1 cmake gcc flatbuffers ninja lz4
];
preBuild = ''
substituteInPlace libcaer.pc --replace // /
'';
};
aestream = pkgs.stdenv.mkDerivation {
name = "aestream";
version = "0.5.0";
src = ./.;
nativeBuildInputs = [
pkgs.cmake
pkgs.gcc
pkgs.autoPatchelfHook
];
buildInputs = [
pkgs.flatbuffers
pkgs.python39
pkgs.ninja
pkgs.lz4
py.torch
libcaer
];
cmakeFlags = [
"-GNinja"
"-DCMAKE_PREFIX_PATH=${py.torch}"
"-DCMAKE_SKIP_BUILD_RPATH=ON"
"-DFLATBUFFERS_SOURCE_DIR=${pkgs.flatbuffers.src}"
];
preBuild = ''
addAutoPatchelfSearchPath src/
addAutoPatchelfSearchPath src/file
addAutoPatchelfSearchPath src/input
addAutoPatchelfSearchPath src/output
'';
installPhase = ''
install -m555 -D -t $out/lib/ src/*.so src/file/*.so src/input/*.so src/output/*.so
install -m755 -D src/aestream $out/bin/aestream
'';
};
aestream-test = aestream.overrideAttrs (parent: {
name = "aestream_test";
nativeBuildInputs = parent.nativeBuildInputs ++ [
pkgs.makeWrapper
];
buildInputs = parent.buildInputs ++ [
pkgs.gtest
];
cmakeFlags = parent.cmakeFlags ++ [
"-DCMAKE_BUILD_TYPE=Debug"
"-DCMAKE_PREFIX_PATH=${py.torch};${pkgs.gtest}"
];
installPhase = parent.installPhase + ''
install -m555 -D $src/example/sample.aedat4 $out/example/sample.aedat4
install -m555 -D $src/example/sample.dat $out/example/sample.dat
install -m755 -D test/aestream_test $out/bin/aestream_test
'';
});
aestream-python = mach-nix.lib.${system}.buildPythonPackage {
pname = "aestream";
version = "0.5.0";
src = ./.;
requirements = "scikit-build\nnumpy";
providers.pip = "wheel";
buildInputs = [ pkgs.lz4 pkgs.zlib py.pybind11 libcaer pkgs.torch ];
nativeBuildInputs = [
pkgs.cmake
pkgs.which
];
python = "python310";
# pypiDataRev = "c8a55398a0e24b5560732cc94cb24172eaddf72f";
# pypiDataSha256 = "sha256-8geJawMHqrwk/+Dvx5pkm/T9BzVJPFqN0leHe3VSsQg=";
postShellHook = ''
echo ${pkgs.torch}
# export LD_LIBRARY_PATH=${pkgs.glibc.bin}:$LD_LIBRARY_PATH
'';
};
in
rec {
devShells = flake-utils.lib.flattenTree {
default = aestream;
python = aestream-python;
};
packages = flake-utils.lib.flattenTree {
default = aestream;
test = aestream-test;
};
}
);
}