Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixpkgs-unstable
- run: nix-channel --update

- name: Install ArrayFire
run: brew install arrayfire
Expand All @@ -33,6 +37,15 @@ jobs:
- name: Configure
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

- name: Build
run: cabal build arrayfire
- name: hspec-discover
run: nix-shell -p ghc -p cabal-install --keep LD_LIBRARY_PATH --run 'cabal install hspec-discover'

- name: Build
run: nix-shell -p ghc -p cabal-install --keep LD_LIBRARY_PATH --run 'cabal build'
env:
LD_LIBRARY_PATH: "/opt/arrayfire/lib:/opt/arrayfire/lib64"

- name: Nix build
run: nix build
env:
LD_LIBRARY_PATH: "/opt/arrayfire/lib:/opt/arrayfire/lib64"
24 changes: 0 additions & 24 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 36 additions & 10 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
nix-filter.url = "github:numtide/nix-filter";
arrayfire-nix = {
url = "github:twesterhout/arrayfire-nix";
inputs.flake-utils.follows = "flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = inputs:
Expand All @@ -30,13 +25,47 @@
];
};

# 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 ];
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; })
(hself.callCabal2nix "arrayfire" src {
af = self.arrayfire;
})
[ "-f disable-default-paths" ];
});
};
Expand All @@ -56,8 +85,6 @@
doctest
hsc2hs
hspec-discover
# Language servers
haskell-language-server
nil
# Formatters
nixpkgs-fmt
Expand All @@ -69,7 +96,7 @@
pkgs-for = system: import inputs.nixpkgs {
inherit system;
overlays = [
inputs.arrayfire-nix.overlays.default
arrayfire-overlay
arrayfire-haskell-overlay
];
};
Expand All @@ -78,7 +105,6 @@
packages = inputs.flake-utils.lib.eachDefaultSystemMap (system:
with (pkgs-for system); {
default = haskellPackages.arrayfire;
haskell = haskell.packages;
});

devShells = inputs.flake-utils.lib.eachDefaultSystemMap (system: {
Expand Down
Loading