Skip to content

Commit 2c3fbe0

Browse files
committed
nix updates
- change shellHooks to use runhaskell instead of cabal-v1 - extend LD_LIBRARY_PATH to include $AF_LIB - ghcid shellHook uses -fno-nocode - get tests to build and _almost_ pass
1 parent 9cda0c6 commit 2c3fbe0

8 files changed

+119
-177
lines changed

default.nix

+27-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
1-
{ pkgs ? import <nixpkgs> { config.allowUnfree = true; } }:
2-
# Latest arrayfire is not yet procured w/ nix.
3-
let
4-
pkg = pkgs.haskellPackages.callCabal2nix "arrayfire" ./. {
5-
af = null;
6-
quickcheck-classes = pkgs.haskellPackages.quickcheck-classes_0_6_4_0;
1+
{ pkgs ? import ./nix/nixpkgs.nix
2+
, compiler ? "ghc865"
3+
}:
4+
5+
with pkgs;
6+
7+
with rec {
8+
hsPkgs = haskell.packages.${compiler}.override {
9+
overrides = hself: hsuper: {
10+
arrayfire = hsLib.overrideCabal (hself.callPackage ./pkg.nix { af = pkgs.arrayfire; }) (old: {
11+
configureFlags = (old.configureFlags or []) ++ [
12+
"-f+disable-default-paths"
13+
"--extra-include-dirs=${arrayfire}/include"
14+
"--extra-lib-dirs=${arrayfire}/lib"
15+
];
16+
17+
doCheck = true;
18+
doHaddock = false;
19+
});
20+
};
721
};
8-
in
9-
pkg
22+
23+
hsLib = haskell.lib;
24+
};
25+
26+
rec {
27+
inherit compiler pkgs hsPkgs;
28+
}

nix/default.nix

-79
This file was deleted.

nix/nixpkgs.nix

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
with {
2+
rev = "9fe4e068123146afda5f2b9a6d630ba76d1daff5";
3+
sha256 = "1fwjf3gvhinzs9yvp7dh3im0123lbzhfrg371ingp61n7jkb73c9";
4+
5+
config = {
6+
allowUnfree = true;
7+
};
8+
9+
overlays = [];
10+
};
11+
12+
import (builtins.fetchTarball {
13+
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
14+
inherit sha256;
15+
}) { inherit config overlays; }

nix/no-download.patch

-28
This file was deleted.

pkg.nix

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
{ mkDerivation, base, directory, parsec, stdenv, text, vector
2-
, hspec, hspec-discover
1+
{ mkDerivation, af, base, directory, filepath, hspec
2+
, hspec-discover, parsec, QuickCheck, quickcheck-classes, stdenv
3+
, text, vector
34
}:
45
mkDerivation {
56
pname = "arrayfire";
67
version = "0.4.0.0";
78
src = ./.;
89
isLibrary = true;
910
isExecutable = true;
10-
libraryHaskellDepends = [ base vector ];
11-
executableHaskellDepends = [ base directory parsec text ];
12-
testHaskellDepends = [ hspec hspec-discover ];
11+
libraryHaskellDepends = [ base filepath vector ];
12+
librarySystemDepends = [ af ];
13+
executableHaskellDepends = [ base directory parsec text vector ];
14+
testHaskellDepends = [
15+
base directory hspec hspec-discover QuickCheck quickcheck-classes
16+
vector
17+
];
18+
testToolDepends = [ hspec-discover ];
1319
homepage = "https://github.com/arrayfire/arrayfire-haskell";
14-
description = "Haskell bindings to ArrayFire";
20+
description = "Haskell bindings to the ArrayFire general-purpose GPU library";
1521
license = stdenv.lib.licenses.bsd3;
1622
}

release.nix

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
ghc844 = (import ./default.nix { compiler = "ghc844"; }).hsPkgs.arrayfire;
3+
ghc865 = (import ./default.nix { compiler = "ghc865"; }).hsPkgs.arrayfire;
4+
ghc881 = (import ./default.nix { compiler = "ghc881"; }).hsPkgs.arrayfire;
5+
}

shell.nix

+54-40
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,54 @@
1-
{ pkgs ? import <nixpkgs> {} }:
2-
let
3-
pkg = (import ./default.nix {}).env;
4-
in
5-
pkgs.lib.overrideDerivation pkg (drv: {
6-
shellHook = ''
7-
export AF_PRINT_ERRORS=1
8-
export PATH=$PATH:${pkgs.haskellPackages.doctest}/bin
9-
export PATH=$PATH:${pkgs.haskellPackages.cabal-install}/bin
10-
function ghcid () {
11-
${pkgs.haskellPackages.ghcid.bin}/bin/ghcid -c 'cabal v1-repl lib:arrayfire'
12-
};
13-
function test-runner () {
14-
${pkgs.ag}/bin/ag -l | \
15-
${pkgs.entr}/bin/entr sh -c \
16-
'cabal v1-configure --enable-tests && \
17-
cabal v1-build test && dist/build/test/test'
18-
}
19-
function test () {
20-
cabal v1-configure --enable-tests && \
21-
cabal v1-build test && dist/build/test/test
22-
}
23-
function doctest-runner () {
24-
${pkgs.ag}/bin/ag -l | \
25-
${pkgs.entr}/bin/entr sh -c \
26-
'cabal v1-configure --enable-tests && \
27-
cabal v1-build doctests && dist/build/doctests/doctests src/ArrayFire/Algorithm.hs'
28-
}
29-
function exe () {
30-
cabal run main
31-
}
32-
function repl () {
33-
cabal v1-repl lib:arrayfire
34-
}
35-
function docs () {
36-
cabal haddock
37-
open ./dist-newstyle/*/*/*/*/doc/html/arrayfire/index.html
38-
}
39-
'';
40-
})
1+
with (import ./default.nix {});
2+
3+
pkgs.lib.overrideDerivation hsPkgs.arrayfire.env (drv: {
4+
shellHook = ''
5+
export AF_PRINT_ERRORS=1
6+
export PATH=$PATH:${hsPkgs.doctest}/bin
7+
8+
export AF_LIB=${pkgs.arrayfire}/lib
9+
export AF_INCLUDE=${pkgs.arrayfire}/include
10+
export LD_LIBRARY_PATH="$AF_LIB:$LD_LIBRARY_PATH"
11+
12+
echo $LD_LIBRARY_PATH
13+
14+
export RUN_HS="runhaskell Setup.hs"
15+
export CFLAGS="-f+disable-default-paths --extra-include-dirs=$AF_INCLUDE --extra-lib-dirs=$AF_LIB"
16+
export CONFIGURE="$RUN_HS configure $CFLAGS"
17+
18+
function ghcid () {
19+
$CONFIGURE && \
20+
${pkgs.ghcid}/bin/ghcid \
21+
-c '$RUN_HS repl --repl-options=-fno-code lib:arrayfire'
22+
}
23+
24+
function test-runner () {
25+
$CONFIGURE --enable-tests && \
26+
${pkgs.ag}/bin/ag -l | \
27+
${pkgs.entr}/bin/entr sh -c \
28+
'$RUN_HS build test && dist/build/test/test'
29+
}
30+
31+
function test() {
32+
$CONFIGURE --enable-tests && \
33+
$RUN_HS build test && dist/build/test/test
34+
}
35+
36+
function doctest-runner () {
37+
${pkgs.ag}/bin/ag -l | \
38+
${pkgs.entr}/bin/entr sh -c \
39+
'$CONFIGURE --enable-tests && \
40+
$RUN_HS build doctests && \
41+
dist/build/doctests/doctests src/ArrayFire/Algorithm.hs'
42+
}
43+
function exe () {
44+
cabal run main
45+
}
46+
function repl () {
47+
$CONFIGURE && $RUN_HS repl lib:arrayfire
48+
}
49+
function docs () {
50+
cabal haddock
51+
open ./dist-newstyle/*/*/*/*/doc/html/arrayfire/index.html
52+
}
53+
'';
54+
})

test/Main.hs

+6-16
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,14 @@ instance (A.AFType a, Arbitrary a) => Arbitrary (Array a) where
2020

2121
main :: IO ()
2222
main = do
23-
-- checks (Proxy :: Proxy (A.Array (A.Complex Float)))
24-
-- checks (Proxy :: Proxy (A.Array (A.Complex Double)))
25-
-- checks (Proxy :: Proxy (A.Array Double))
26-
-- checks (Proxy :: Proxy (A.Array Float))
27-
-- checks (Proxy :: Proxy (A.Array Double))
28-
-- checks (Proxy :: Proxy (A.Array A.Int16))
29-
-- checks (Proxy :: Proxy (A.Array A.Int32))
30-
-- checks (Proxy :: Proxy (A.Array A.CBool))
31-
-- checks (Proxy :: Proxy (A.Array Word))
32-
-- checks (Proxy :: Proxy (A.Array A.Word8))
33-
-- checks (Proxy :: Proxy (A.Array A.Word16))
34-
-- checks (Proxy :: Proxy (A.Array A.Word32))
35-
-- lawsCheck $ semigroupLaws (Proxy :: Proxy (A.Array Double))
36-
-- lawsCheck $ semigroupLaws (Proxy :: Proxy (A.Array Float))
23+
lawsCheck $ eqLaws (Proxy @(A.Complex Double))
3724
hspec spec
3825

26+
p :: Proxy (Array a)
27+
p = Proxy
28+
3929
checks proxy = do
40-
lawsCheck (numLaws proxy)
30+
-- lawsCheck (numLaws proxy)
4131
lawsCheck (eqLaws proxy)
4232
lawsCheck (ordLaws proxy)
43-
-- lawsCheck (semigroupLaws proxy)
33+
-- lawsCheck (semigroupLaws proxy)

0 commit comments

Comments
 (0)