From 4be13503c7474a4b84e8fbb7ffdb2e6587c21370 Mon Sep 17 00:00:00 2001 From: Dominic Steinitz Date: Mon, 9 Apr 2018 15:44:31 +0100 Subject: Almost a complete re-write of shell.nix --- shell.nix | 188 ++++++++++++++++++++------------------------------------------ 1 file changed, 60 insertions(+), 128 deletions(-) (limited to 'shell.nix') diff --git a/shell.nix b/shell.nix index 2166c9a..d22f886 100644 --- a/shell.nix +++ b/shell.nix @@ -1,132 +1,64 @@ -# From Mathieu's PR - -# {ghc}: - -# with import {}; - -# let -# gfortranlibdir = "${gfortran7.cc.lib}"; -# # XXX Workaround https://ghc.haskell.org/trac/ghc/ticket/11042. -# libHack = if stdenv.isDarwin then { -# DYLD_LIBRARY_PATH = [gfortranlibdir]; -# } else { -# LD_LIBRARY_PATH = [gfortranlibdir]; -# }; -# in -# haskell.lib.buildStackProject ({ -# name = "haskell-sundials"; -# buildInputs = [blas liblapack sundials zlib]; -# inherit ghc; -# # XXX Workaround https://ghc.haskell.org/trac/ghc/ticket/11042. -# extraArgs = ["--extra-lib-dirs=${gfortranlibdir}"]; -# } // libHack) - - -# Dominic's original version - -# { nixpkgs ? import -# {} -# , compiler ? "ghc822" -# , doBenchmark ? false }: - -# let - -# inherit (nixpkgs) pkgs; - -# f = { mkDerivation, ad, base, diagrams-lib, diagrams-rasterific, gcc -# , hmatrix, hmatrix-gsl, HUnit, inline-c, plots, pretty, QuickCheck, stdenv, sundials, vector }: - -# mkDerivation { -# pname = "haskell-sundials"; -# version = "0.1.0.0"; -# src = ./.; -# isLibrary = false; -# isExecutable = true; -# executableHaskellDepends = [ -# ad -# base -# diagrams-lib -# diagrams-rasterific -# gcc -# hmatrix -# hmatrix-gsl -# HUnit -# inline-c -# plots -# QuickCheck -# pretty -# vector -# ] ++ (if pkgs.stdenv.isDarwin then [pkgs.darwin.apple_sdk.frameworks.Cocoa] else []); -# executableSystemDepends = [ -# pkgs.blas -# pkgs.gfortran.cc -# pkgs.liblapack -# pkgs.gsl -# pkgs.glpk -# pkgs.pkgconfig -# pkgs.stack -# sundials -# pkgs.zlib -# ] ++ (if pkgs.stdenv.isDarwin then [pkgs.darwin.apple_sdk.frameworks.Accelerate] else []); -# license = stdenv.lib.licenses.bsd3; -# }; - -# haskellPackages = if compiler == "default" -# then pkgs.haskellPackages -# else pkgs.haskell.packages.${compiler}; - -# variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id; - -# drv = variant (haskellPackages.callPackage f {}); - -# in - -# if pkgs.lib.inNixShell then drv.env else drv +{ nixpkgs ? import {} +, compiler ? "ghc822", doBenchmark ? false }: let - pkgs = import ./nixpkgs.nix {}; - - # List of dependencies, these are provided as - # - extra-lib-dirs to stack for linking - # - buildInputs so that the headers are available during compilation - extraLibs = - [ - pkgs.blas - pkgs.gfortran7.cc - pkgs.glpk - pkgs.gsl - pkgs.liblapack - pkgs.sundials - pkgs.zlib # the library - pkgs.zlib.dev # the headers - ]; - - # Wrapped stack executable that uses the nix-provided GHC - stack = pkgs.stdenv.mkDerivation { - name = "stack-system-ghc"; - builder = pkgs.writeScript "stack" '' - source $stdenv/setup - mkdir -p $out/bin - makeWrapper ${pkgs.stack}/bin/stack $out/bin/stack \ - --add-flags "--extra-include-dirs=${pkgs.zlib.dev}/include" \ - --add-flags "--extra-lib-dirs=${pkgs.lib.makeLibraryPath extraLibs}" - ''; - buildInputs = [ pkgs.makeWrapper ]; - }; - ghc = pkgs.haskell.compiler.ghc822; - ldLibraryPath = if pkgs.stdenv.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH"; - -in pkgs.mkShell - { buildInputs = [ stack ghc ] ++ extraLibs; - - # Cabal only accepts gsl through pkg-config - PKG_CONFIG_PATH="${pkgs.gsl}/lib/pkgconfig"; - # For reasons that are beyond me stack fails to pass in zlib as an extra - # lib - ${ldLibraryPath} = "${pkgs.zlib}/lib"; + inherit (nixpkgs) pkgs; + +f = { mkDerivation, base, containers, diagrams-lib, diagrams-rasterific, gcc + , hmatrix, hmatrix-gsl, HUnit, inline-c, plots, stdenv + , template-haskell, temporary, vector }: + +mkDerivation { + pname = "hmatrix-sundials"; + version = "0.1.0.0"; + src = ./.; + isLibrary = true; + isExecutable = true; + libraryHaskellDepends = [ + base + containers + hmatrix + inline-c + template-haskell + vector + ]; + executableHaskellDepends = [ + base + diagrams-lib + diagrams-rasterific + gcc + hmatrix + hmatrix-gsl + HUnit + inline-c + template-haskell + temporary + vector + ] ++ (if pkgs.stdenv.isDarwin then [pkgs.darwin.apple_sdk.frameworks.Cocoa] else []); + executableSystemDepends = [ + pkgs.blas + pkgs.gfortran.cc + pkgs.liblapack + pkgs.gsl + pkgs.glpk + pkgs.pkgconfig + pkgs.stack + pkgs.sundials + pkgs.zlib + ] ++ (if pkgs.stdenv.isDarwin then [pkgs.darwin.apple_sdk.frameworks.Accelerate] else []); + license = stdenv.lib.licenses.bsd3; +}; + + haskellPackages = if compiler == "default" + then pkgs.haskellPackages + else pkgs.haskell.packages.${compiler}; + + variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id; + + drv = variant (haskellPackages.callPackage f {}); + +in + + if pkgs.lib.inNixShell then drv.env else drv - # For some reasons that are beyond me stack fails to pass in liblapack as a - # static lib to the linker - LIBRARY_PATH="${pkgs.liblapack}/lib"; - } -- cgit v1.2.3