diff options
-rw-r--r-- | shell.nix | 159 | ||||
-rw-r--r-- | stack.yaml | 6 |
2 files changed, 107 insertions, 58 deletions
@@ -22,61 +22,110 @@ | |||
22 | # } // libHack) | 22 | # } // libHack) |
23 | 23 | ||
24 | 24 | ||
25 | { nixpkgs ? import <nixpkgs> | 25 | # Dominic's original version |
26 | {} | 26 | |
27 | , compiler ? "ghc822" | 27 | # { nixpkgs ? import <nixpkgs> |
28 | , doBenchmark ? false }: | 28 | # {} |
29 | # , compiler ? "ghc822" | ||
30 | # , doBenchmark ? false }: | ||
31 | |||
32 | # let | ||
33 | |||
34 | # inherit (nixpkgs) pkgs; | ||
35 | |||
36 | # f = { mkDerivation, ad, base, diagrams-lib, diagrams-rasterific, gcc | ||
37 | # , hmatrix, hmatrix-gsl, HUnit, inline-c, plots, pretty, QuickCheck, stdenv, sundials, vector }: | ||
38 | |||
39 | # mkDerivation { | ||
40 | # pname = "haskell-sundials"; | ||
41 | # version = "0.1.0.0"; | ||
42 | # src = ./.; | ||
43 | # isLibrary = false; | ||
44 | # isExecutable = true; | ||
45 | # executableHaskellDepends = [ | ||
46 | # ad | ||
47 | # base | ||
48 | # diagrams-lib | ||
49 | # diagrams-rasterific | ||
50 | # gcc | ||
51 | # hmatrix | ||
52 | # hmatrix-gsl | ||
53 | # HUnit | ||
54 | # inline-c | ||
55 | # plots | ||
56 | # QuickCheck | ||
57 | # pretty | ||
58 | # vector | ||
59 | # ] ++ (if pkgs.stdenv.isDarwin then [pkgs.darwin.apple_sdk.frameworks.Cocoa] else []); | ||
60 | # executableSystemDepends = [ | ||
61 | # pkgs.blas | ||
62 | # pkgs.gfortran.cc | ||
63 | # pkgs.liblapack | ||
64 | # pkgs.gsl | ||
65 | # pkgs.glpk | ||
66 | # pkgs.pkgconfig | ||
67 | # pkgs.stack | ||
68 | # sundials | ||
69 | # pkgs.zlib | ||
70 | # ] ++ (if pkgs.stdenv.isDarwin then [pkgs.darwin.apple_sdk.frameworks.Accelerate] else []); | ||
71 | # license = stdenv.lib.licenses.bsd3; | ||
72 | # }; | ||
73 | |||
74 | # haskellPackages = if compiler == "default" | ||
75 | # then pkgs.haskellPackages | ||
76 | # else pkgs.haskell.packages.${compiler}; | ||
77 | |||
78 | # variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id; | ||
79 | |||
80 | # drv = variant (haskellPackages.callPackage f {}); | ||
81 | |||
82 | # in | ||
83 | |||
84 | # if pkgs.lib.inNixShell then drv.env else drv | ||
29 | 85 | ||
30 | let | 86 | let |
87 | pkgs = import ./nixpkgs.nix {}; | ||
88 | |||
89 | # List of dependencies, these are provided as | ||
90 | # - extra-lib-dirs to stack for linking | ||
91 | # - buildInputs so that the headers are available during compilation | ||
92 | extraLibs = | ||
93 | [ | ||
94 | pkgs.blas | ||
95 | pkgs.gfortran7.cc | ||
96 | pkgs.glpk | ||
97 | pkgs.gsl | ||
98 | pkgs.liblapack | ||
99 | pkgs.sundials | ||
100 | pkgs.zlib # the library | ||
101 | pkgs.zlib.dev # the headers | ||
102 | ]; | ||
103 | |||
104 | # Wrapped stack executable that uses the nix-provided GHC | ||
105 | stack = pkgs.stdenv.mkDerivation { | ||
106 | name = "stack-system-ghc"; | ||
107 | builder = pkgs.writeScript "stack" '' | ||
108 | source $stdenv/setup | ||
109 | mkdir -p $out/bin | ||
110 | makeWrapper ${pkgs.stack}/bin/stack $out/bin/stack \ | ||
111 | --add-flags "--extra-lib-dirs=${pkgs.lib.makeLibraryPath extraLibs}" | ||
112 | ''; | ||
113 | buildInputs = [ pkgs.makeWrapper ]; | ||
114 | }; | ||
115 | ghc = pkgs.haskell.compiler.ghc822; | ||
116 | ldLibraryPath = if pkgs.stdenv.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH"; | ||
117 | |||
118 | in pkgs.mkShell | ||
119 | { buildInputs = [ stack ghc ] ++ extraLibs; | ||
120 | |||
121 | # Cabal only accepts gsl through pkg-config | ||
122 | PKG_CONFIG_PATH="${pkgs.gsl}/lib/pkgconfig"; | ||
123 | |||
124 | # For reasons that are beyond me stack fails to pass in zlib as an extra | ||
125 | # lib | ||
126 | ${ldLibraryPath} = "${pkgs.zlib}/lib"; | ||
31 | 127 | ||
32 | inherit (nixpkgs) pkgs; | 128 | # For some reasons that are beyond me stack fails to pass in liblapack as a |
33 | 129 | # static lib to the linker | |
34 | f = { mkDerivation, ad, base, diagrams-lib, diagrams-rasterific, gcc | 130 | LIBRARY_PATH="${pkgs.liblapack}/lib"; |
35 | , hmatrix, hmatrix-gsl, HUnit, inline-c, plots, pretty, QuickCheck, stdenv, sundials, vector }: | 131 | } |
36 | |||
37 | mkDerivation { | ||
38 | pname = "haskell-sundials"; | ||
39 | version = "0.1.0.0"; | ||
40 | src = ./.; | ||
41 | isLibrary = false; | ||
42 | isExecutable = true; | ||
43 | executableHaskellDepends = [ | ||
44 | ad | ||
45 | base | ||
46 | diagrams-lib | ||
47 | diagrams-rasterific | ||
48 | gcc | ||
49 | hmatrix | ||
50 | hmatrix-gsl | ||
51 | HUnit | ||
52 | inline-c | ||
53 | plots | ||
54 | QuickCheck | ||
55 | pretty | ||
56 | vector | ||
57 | ] ++ (if pkgs.stdenv.isDarwin then [pkgs.darwin.apple_sdk.frameworks.Cocoa] else []); | ||
58 | executableSystemDepends = [ | ||
59 | pkgs.blas | ||
60 | pkgs.gfortran.cc | ||
61 | pkgs.liblapack | ||
62 | pkgs.gsl | ||
63 | pkgs.glpk | ||
64 | pkgs.pkgconfig | ||
65 | pkgs.stack | ||
66 | sundials | ||
67 | pkgs.zlib | ||
68 | ] ++ (if pkgs.stdenv.isDarwin then [pkgs.darwin.apple_sdk.frameworks.Accelerate] else []); | ||
69 | license = stdenv.lib.licenses.bsd3; | ||
70 | }; | ||
71 | |||
72 | haskellPackages = if compiler == "default" | ||
73 | then pkgs.haskellPackages | ||
74 | else pkgs.haskell.packages.${compiler}; | ||
75 | |||
76 | variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id; | ||
77 | |||
78 | drv = variant (haskellPackages.callPackage f {}); | ||
79 | |||
80 | in | ||
81 | |||
82 | if pkgs.lib.inNixShell then drv.env else drv | ||
@@ -18,6 +18,6 @@ extra-deps: | |||
18 | - diagrams-rasterific-1.4 | 18 | - diagrams-rasterific-1.4 |
19 | - plots-0.1.0.2 | 19 | - plots-0.1.0.2 |
20 | resolver: lts-10.9 | 20 | resolver: lts-10.9 |
21 | nix: | 21 | # nix: |
22 | path: [nixpkgs=./nixpkgs.nix] | 22 | # path: [nixpkgs=./nixpkgs.nix] |
23 | shell-file: shell.nix | 23 | # shell-file: shell.nix |