summaryrefslogtreecommitdiff
path: root/shell.nix
diff options
context:
space:
mode:
authorDominic Steinitz <dominic@steinitz.org>2018-04-09 15:44:31 +0100
committerDominic Steinitz <dominic@steinitz.org>2018-04-09 15:44:31 +0100
commit4be13503c7474a4b84e8fbb7ffdb2e6587c21370 (patch)
tree38040fcab8bd30cf6eef08318c8a4ef8b97dfc23 /shell.nix
parente022e6b2d96f89376113241d89e31e2affd4faaf (diff)
Almost a complete re-write of shell.nix
Diffstat (limited to 'shell.nix')
-rw-r--r--shell.nix188
1 files changed, 60 insertions, 128 deletions
diff --git a/shell.nix b/shell.nix
index 2166c9a..d22f886 100644
--- a/shell.nix
+++ b/shell.nix
@@ -1,132 +1,64 @@
1# From Mathieu's PR 1{ nixpkgs ? import <nixpkgs> {}
2 2, compiler ? "ghc822", doBenchmark ? false }:
3# {ghc}:
4
5# with import <nixpkgs> {};
6
7# let
8# gfortranlibdir = "${gfortran7.cc.lib}";
9# # XXX Workaround https://ghc.haskell.org/trac/ghc/ticket/11042.
10# libHack = if stdenv.isDarwin then {
11# DYLD_LIBRARY_PATH = [gfortranlibdir];
12# } else {
13# LD_LIBRARY_PATH = [gfortranlibdir];
14# };
15# in
16# haskell.lib.buildStackProject ({
17# name = "haskell-sundials";
18# buildInputs = [blas liblapack sundials zlib];
19# inherit ghc;
20# # XXX Workaround https://ghc.haskell.org/trac/ghc/ticket/11042.
21# extraArgs = ["--extra-lib-dirs=${gfortranlibdir}"];
22# } // libHack)
23
24
25# Dominic's original version
26
27# { nixpkgs ? import <nixpkgs>
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
85 3
86let 4let
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-include-dirs=${pkgs.zlib.dev}/include" \
112 --add-flags "--extra-lib-dirs=${pkgs.lib.makeLibraryPath extraLibs}"
113 '';
114 buildInputs = [ pkgs.makeWrapper ];
115 };
116 ghc = pkgs.haskell.compiler.ghc822;
117 ldLibraryPath = if pkgs.stdenv.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH";
118
119in pkgs.mkShell
120 { buildInputs = [ stack ghc ] ++ extraLibs;
121
122 # Cabal only accepts gsl through pkg-config
123 PKG_CONFIG_PATH="${pkgs.gsl}/lib/pkgconfig";
124 5
125 # For reasons that are beyond me stack fails to pass in zlib as an extra 6 inherit (nixpkgs) pkgs;
126 # lib 7
127 ${ldLibraryPath} = "${pkgs.zlib}/lib"; 8f = { mkDerivation, base, containers, diagrams-lib, diagrams-rasterific, gcc
9 , hmatrix, hmatrix-gsl, HUnit, inline-c, plots, stdenv
10 , template-haskell, temporary, vector }:
11
12mkDerivation {
13 pname = "hmatrix-sundials";
14 version = "0.1.0.0";
15 src = ./.;
16 isLibrary = true;
17 isExecutable = true;
18 libraryHaskellDepends = [
19 base
20 containers
21 hmatrix
22 inline-c
23 template-haskell
24 vector
25 ];
26 executableHaskellDepends = [
27 base
28 diagrams-lib
29 diagrams-rasterific
30 gcc
31 hmatrix
32 hmatrix-gsl
33 HUnit
34 inline-c
35 template-haskell
36 temporary
37 vector
38 ] ++ (if pkgs.stdenv.isDarwin then [pkgs.darwin.apple_sdk.frameworks.Cocoa] else []);
39 executableSystemDepends = [
40 pkgs.blas
41 pkgs.gfortran.cc
42 pkgs.liblapack
43 pkgs.gsl
44 pkgs.glpk
45 pkgs.pkgconfig
46 pkgs.stack
47 pkgs.sundials
48 pkgs.zlib
49 ] ++ (if pkgs.stdenv.isDarwin then [pkgs.darwin.apple_sdk.frameworks.Accelerate] else []);
50 license = stdenv.lib.licenses.bsd3;
51};
52
53 haskellPackages = if compiler == "default"
54 then pkgs.haskellPackages
55 else pkgs.haskell.packages.${compiler};
56
57 variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id;
58
59 drv = variant (haskellPackages.callPackage f {});
60
61in
62
63 if pkgs.lib.inNixShell then drv.env else drv
128 64
129 # For some reasons that are beyond me stack fails to pass in liblapack as a
130 # static lib to the linker
131 LIBRARY_PATH="${pkgs.liblapack}/lib";
132 }