-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathflake.nix
More file actions
120 lines (111 loc) · 3.49 KB
/
Copy pathflake.nix
File metadata and controls
120 lines (111 loc) · 3.49 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
{
description = "arrayfire/arrayfire-haskell: ArrayFire Haskell bindings";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
nix-filter.url = "github:numtide/nix-filter";
};
outputs = inputs:
let
src = inputs.nix-filter.lib {
root = ./.;
include = [
"cbits"
"exe"
"gen"
"include"
"src"
"test"
"arrayfire.cabal"
"README.md"
"CHANGELOG.md"
"LICENSE"
];
};
# Build ArrayFire from the official binary installer; avoids freeimage entirely.
mkArrayfire = pkgs: pkgs.stdenv.mkDerivation rec {
pname = "arrayfire";
version = "3.10.0";
src = pkgs.fetchurl {
url = "https://arrayfire.s3.amazonaws.com/${version}/ArrayFire-v${version}_Linux_x86_64.sh";
hash = "sha256-8SibCWnRxts79S6WEHb3skF2TIDl1QnjY6EiohmoIog=";
};
nativeBuildInputs = [ pkgs.autoPatchelfHook ];
# GPU/visualization libs (CUDA, OpenGL, GLFW, FreeImage, Intel OpenCL) are
# optional ArrayFire backends not available in headless CI environments.
autoPatchelfIgnoreMissingDeps = true;
buildInputs = with pkgs; [
stdenv.cc.cc.lib
fftw
fftwFloat
openblas
ocl-icd
boost.out
];
unpackPhase = "true";
installPhase = ''
mkdir -p $out
bash $src --exclude-subdir --prefix=$out
'';
meta = {
description = "A general-purpose library for parallel and massively-parallel architectures";
platforms = [ "x86_64-linux" ];
};
};
arrayfire-overlay = self: super: {
arrayfire = mkArrayfire self;
};
# An overlay that lets us test arrayfire-haskell with different GHC versions
arrayfire-haskell-overlay = self: super: {
haskell = super.haskell // {
packageOverrides = inputs.nixpkgs.lib.composeExtensions super.haskell.packageOverrides
(hself: hsuper: {
arrayfire = self.haskell.lib.appendConfigureFlags
(hself.callCabal2nix "arrayfire" src {
af = self.arrayfire;
})
[ "-f disable-default-paths" ];
});
};
};
devShell-for = pkgs:
let
ps = pkgs.haskellPackages;
in
ps.shellFor {
packages = ps: with ps; [ arrayfire ];
withHoogle = true;
buildInputs = with pkgs; [ ocl-icd ];
nativeBuildInputs = with pkgs; with ps; [
# Building and testing
cabal-install
doctest
hsc2hs
# hspec-discover
nil
# Formatters
nixpkgs-fmt
];
shellHook = ''
export LD_LIBRARY_PATH="${pkgs.arrayfire}/lib:$LD_LIBRARY_PATH"
'';
};
pkgs-for = system: import inputs.nixpkgs {
inherit system;
overlays = [
arrayfire-overlay
arrayfire-haskell-overlay
];
};
in
{
packages = inputs.flake-utils.lib.eachDefaultSystemMap (system:
with (pkgs-for system); {
default = haskellPackages.arrayfire;
});
devShells = inputs.flake-utils.lib.eachDefaultSystemMap (system: {
default = devShell-for (pkgs-for system);
});
overlays.default = arrayfire-haskell-overlay;
};
}