forked from nbren12/call_py_fort
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
41 lines (38 loc) · 1.1 KB
/
default.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{ lib, pfunit, stdenv, gfortran, cmakeCurses, cmake, pythonPackages
, llvmPackages }:
let appleSilicon = (stdenv.isAarch64 && stdenv.isDarwin);
in stdenv.mkDerivation {
name = "call_py_fort";
src = ./.;
nativeBuildInputs = (lib.optional stdenv.isDarwin llvmPackages.openmp
++ lib.optional (!appleSilicon) pfunit);
buildInputs = [
gfortran
gfortran.cc.lib
cmake
cmakeCurses
gfortran.cc
pythonPackages.python
];
propagatedBuildInputs = [ pythonPackages.cffi pythonPackages.numpy ];
doCheck = true;
preCheck = ''
export PYTHONPATH=$(pwd)/../test:$PYTHONPATH
# for mac
export DYLD_LIBRARY_PATH=$(pwd)/src
# for linux
export LD_LIBRARY_PATH=$(pwd)/src
'';
shellHook = ''
export PYTHONPATH=$(pwd)/test:$PYTHONPATH
export PYTHONPATH=$(pwd)/examples:$PYTHONPATH
# for mac
export DYLD_LIBRARY_PATH=$(pwd)/src
# for linux
export LD_LIBRARY_PATH=$(pwd)/src
# to help find the right python
export Python_ROOT_DIR=${pythonPackages.python}
'';
# inherit pfunit;
hardeningDisable = lib.optionals (appleSilicon) [ "stackprotector" ];
}