Skip to content

Commit 3915cda

Browse files
committed
Update nix build
1 parent 50ce116 commit 3915cda

3 files changed

Lines changed: 48 additions & 36 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ jobs:
1212

1313
steps:
1414
- uses: actions/checkout@v4
15+
- uses: cachix/install-nix-action@v31
16+
with:
17+
nix_path: nixpkgs=channel:nixpkgs-unstable
18+
- run: nix-channel --update
1519

1620
- name: Install ArrayFire
1721
run: brew install arrayfire
@@ -34,5 +38,11 @@ jobs:
3438
run: cabal configure --flags="disable-default-paths disable-build-tool-depends" --extra-include-dirs=$(brew --prefix arrayfire)/include --extra-lib-dirs=$(brew --prefix arrayfire)/lib
3539

3640
- name: Build
37-
run: cabal build arrayfire
38-
41+
run: nix-shell -p ghc -p cabal-install --keep LD_LIBRARY_PATH --run 'cabal build'
42+
env:
43+
LD_LIBRARY_PATH: "/opt/arrayfire/lib:/opt/arrayfire/lib64"
44+
45+
- name: Nix build
46+
run: nix build
47+
env:
48+
LD_LIBRARY_PATH: "/opt/arrayfire/lib:/opt/arrayfire/lib64"

flake.lock

Lines changed: 0 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
66
flake-utils.url = "github:numtide/flake-utils";
77
nix-filter.url = "github:numtide/nix-filter";
8-
arrayfire-nix = {
9-
url = "github:twesterhout/arrayfire-nix";
10-
inputs.flake-utils.follows = "flake-utils";
11-
inputs.nixpkgs.follows = "nixpkgs";
12-
};
138
};
149

1510
outputs = inputs:
@@ -30,13 +25,47 @@
3025
];
3126
};
3227

28+
# Build ArrayFire from the official binary installer; avoids freeimage entirely.
29+
mkArrayfire = pkgs: pkgs.stdenv.mkDerivation rec {
30+
pname = "arrayfire";
31+
version = "3.10.0";
32+
src = pkgs.fetchurl {
33+
url = "https://arrayfire.s3.amazonaws.com/${version}/ArrayFire-v${version}_Linux_x86_64.sh";
34+
hash = "sha256-8SibCWnRxts79S6WEHb3skF2TIDl1QnjY6EiohmoIog=";
35+
};
36+
nativeBuildInputs = [ pkgs.autoPatchelfHook ];
37+
buildInputs = with pkgs; [
38+
stdenv.cc.cc.lib
39+
fftw
40+
fftwFloat
41+
openblas
42+
ocl-icd
43+
boost.out
44+
];
45+
unpackPhase = "true";
46+
installPhase = ''
47+
mkdir -p $out
48+
bash $src --exclude-subdir --prefix=$out
49+
'';
50+
meta = {
51+
description = "A general-purpose library for parallel and massively-parallel architectures";
52+
platforms = [ "x86_64-linux" ];
53+
};
54+
};
55+
56+
arrayfire-overlay = self: super: {
57+
arrayfire = mkArrayfire self;
58+
};
59+
3360
# An overlay that lets us test arrayfire-haskell with different GHC versions
3461
arrayfire-haskell-overlay = self: super: {
3562
haskell = super.haskell // {
3663
packageOverrides = inputs.nixpkgs.lib.composeExtensions super.haskell.packageOverrides
3764
(hself: hsuper: {
3865
arrayfire = self.haskell.lib.appendConfigureFlags
39-
(hself.callCabal2nix "arrayfire" src { af = self.arrayfire; })
66+
(hself.callCabal2nix "arrayfire" src {
67+
af = self.arrayfire;
68+
})
4069
[ "-f disable-default-paths" ];
4170
});
4271
};
@@ -56,8 +85,6 @@
5685
doctest
5786
hsc2hs
5887
hspec-discover
59-
# Language servers
60-
haskell-language-server
6188
nil
6289
# Formatters
6390
nixpkgs-fmt
@@ -69,7 +96,7 @@
6996
pkgs-for = system: import inputs.nixpkgs {
7097
inherit system;
7198
overlays = [
72-
inputs.arrayfire-nix.overlays.default
99+
arrayfire-overlay
73100
arrayfire-haskell-overlay
74101
];
75102
};
@@ -78,7 +105,6 @@
78105
packages = inputs.flake-utils.lib.eachDefaultSystemMap (system:
79106
with (pkgs-for system); {
80107
default = haskellPackages.arrayfire;
81-
haskell = haskell.packages;
82108
});
83109

84110
devShells = inputs.flake-utils.lib.eachDefaultSystemMap (system: {

0 commit comments

Comments
 (0)