From a9ddbf4f1a54ce82329f9902c8dc11454e2310b0 Mon Sep 17 00:00:00 2001 From: Alejandro Gallo Date: Wed, 13 Oct 2021 12:22:58 +0200 Subject: [PATCH] Add support in nix for mkl --- etc/nix/mkl.nix | 13 +++++++++++++ etc/nix/openblas.nix | 16 ++++++++++++++++ shell.nix | 43 +++++++++++++++++++++++-------------------- 3 files changed, 52 insertions(+), 20 deletions(-) create mode 100644 etc/nix/mkl.nix create mode 100644 etc/nix/openblas.nix diff --git a/etc/nix/mkl.nix b/etc/nix/mkl.nix new file mode 100644 index 0000000..c3f9c40 --- /dev/null +++ b/etc/nix/mkl.nix @@ -0,0 +1,13 @@ +{ pkgs, ...}: + +{ + buildInputs = with pkgs; [ + mkl + ]; + + shellHook = '' + export MKL_PATH=${pkgs.mkl} + export LD_LIBRARY_PATH=$MKL_PATH:$LD_LIBRARY_PATH + ''; +} + diff --git a/etc/nix/openblas.nix b/etc/nix/openblas.nix new file mode 100644 index 0000000..13f4e03 --- /dev/null +++ b/etc/nix/openblas.nix @@ -0,0 +1,16 @@ +{ pkgs, ...}: + +{ + buildInputs = with pkgs; [ + openblas + scalapack + ]; + + shellHook = '' + export OPENBLAS_PATH=${pkgs.openblas} + export SCALAPACK_PATH=${pkgs.scalapack} + export LD_LIBRARY_PATH=${pkgs.scalapack}/lib:$LD_LIBRARY_PATH + ''; +} + + diff --git a/shell.nix b/shell.nix index 7c80d64..3b4e070 100644 --- a/shell.nix +++ b/shell.nix @@ -1,7 +1,13 @@ -{ pkgs ? import {} , with-clang ? false }: +{ pkgs ? import {} , with-clang ? false , with-mkl ? false }: let + mkl = import ./etc/nix/mkl.nix { pkgs = (import { + config.allowUnfree = true; + }); }; + + openblas = import ./etc/nix/openblas.nix { inherit pkgs; }; + clang = import ./etc/nix/clang.nix { inherit pkgs; }; compiler-configuration @@ -13,28 +19,25 @@ in pkgs.mkShell { - buildInputs = with pkgs; [ + buildInputs + = with pkgs; [ - coreutils - git + coreutils + git - blas - openmpi + openmpi - gnumake - binutils - emacs + gnumake + binutils + emacs + ] + ++ compiler-configuration + ++ (if with-mkl then mkl.buildInputs else openblas.buildInputs) + ; - ] ++ compiler-configuration; - - shellHook = '' - export LAPACK_PATH=${pkgs.lapack} - export BLAS_PATH=${pkgs.blas} - export OPENBLAS_PATH=${pkgs.openblas} - export SCALAPACK_PATH=${pkgs.scalapack} - export LD_LIBRARY_PATH=${pkgs.scalapack}/lib:$LD_LIBRARY_PATH - '' - + (if with-clang then clang.shellHook else "") - ; + shellHook + = (if with-clang then clang.shellHook else "") + + (if with-mkl then mkl.shellHook else openblas.shellHook) + ; }