2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
, fetchurl
|
2021-02-05 17:12:51 +00:00
|
|
|
, pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
, automake
|
|
|
|
, autoconf
|
|
|
|
, libtool
|
|
|
|
, ncurses
|
|
|
|
, readline
|
|
|
|
, which
|
|
|
|
, python ? null
|
2021-02-05 17:12:51 +00:00
|
|
|
, useMpi ? false
|
|
|
|
, mpi
|
2020-04-24 23:36:52 +00:00
|
|
|
, iv
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2022-03-05 16:20:37 +00:00
|
|
|
pname = "neuron${lib.optionalString useMpi "-mpi"}";
|
2020-04-24 23:36:52 +00:00
|
|
|
version = "7.5";
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
nativeBuildInputs = [ which pkg-config automake autoconf libtool ];
|
|
|
|
buildInputs = [ ncurses readline python iv ]
|
|
|
|
++ lib.optional useMpi mpi;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://www.neuron.yale.edu/ftp/neuron/versions/v${version}/nrn-${version}.tar.gz";
|
|
|
|
sha256 = "0f26v3qvzblcdjg7isq0m9j2q8q7x3vhmkfllv8lsr3gyj44lljf";
|
|
|
|
};
|
|
|
|
|
2021-01-17 00:15:33 +00:00
|
|
|
patches = (lib.optional (stdenv.isDarwin) [ ./neuron-carbon-disable.patch ]);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# With LLVM 3.8 and above, clang (really libc++) gets upset if you attempt to redefine these...
|
2021-01-17 00:15:33 +00:00
|
|
|
postPatch = lib.optionalString stdenv.cc.isClang ''
|
2020-04-24 23:36:52 +00:00
|
|
|
substituteInPlace src/gnu/neuron_gnu_builtin.h \
|
|
|
|
--replace 'double abs(double arg);' "" \
|
|
|
|
--replace 'float abs(float arg);' "" \
|
|
|
|
--replace 'short abs(short arg);' "" \
|
|
|
|
--replace 'long abs(long arg);' ""
|
2021-01-17 00:15:33 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
2020-04-24 23:36:52 +00:00
|
|
|
# we are darwin, but we don't have all the quirks the source wants to compensate for
|
|
|
|
substituteInPlace src/nrnpython/setup.py.in --replace 'readline="edit"' 'readline="readline"'
|
|
|
|
for f in src/nrnpython/*.[ch] ; do
|
|
|
|
substituteInPlace $f --replace "<Python/Python.h>" "<Python.h>"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
## neuron install by default everything under prefix/${host_arch}/*
|
|
|
|
## override this to support nix standard file hierarchy
|
|
|
|
## without issues: install everything under prefix/
|
|
|
|
preConfigure = ''
|
|
|
|
./build.sh
|
|
|
|
export prefix="''${prefix} --exec-prefix=''${out}"
|
|
|
|
'';
|
|
|
|
|
2021-01-17 00:15:33 +00:00
|
|
|
configureFlags = with lib;
|
2020-04-24 23:36:52 +00:00
|
|
|
[ "--with-readline=${readline}" "--with-iv=${iv}" ]
|
|
|
|
++ optionals (python != null) [ "--with-nrnpython=${python.interpreter}" ]
|
2021-02-05 17:12:51 +00:00
|
|
|
++ (if useMpi then ["--with-mpi" "--with-paranrn"]
|
2020-04-24 23:36:52 +00:00
|
|
|
else ["--without-mpi"]);
|
|
|
|
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
postInstall = lib.optionalString (python != null) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
## standardise python neuron install dir if any
|
|
|
|
if [[ -d $out/lib/python ]]; then
|
|
|
|
mkdir -p ''${out}/${python.sitePackages}
|
|
|
|
mv ''${out}/lib/python/* ''${out}/${python.sitePackages}/
|
|
|
|
fi
|
2021-08-22 07:53:02 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
propagatedBuildInputs = [ readline ncurses which libtool ];
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2022-06-16 17:23:12 +00:00
|
|
|
broken = stdenv.isDarwin;
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Simulation environment for empirically-based simulations of neurons and networks of neurons";
|
|
|
|
|
|
|
|
longDescription = "NEURON is a simulation environment for developing and exercising models of
|
|
|
|
neurons and networks of neurons. It is particularly well-suited to problems where
|
|
|
|
cable properties of cells play an important role, possibly including extracellular
|
|
|
|
potential close to the membrane), and where cell membrane properties are complex,
|
|
|
|
involving many ion-specific channels, ion accumulation, and second messengers";
|
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
sourceProvenance = with sourceTypes; [
|
|
|
|
fromSource
|
|
|
|
] ++ lib.optionals (python != null) [
|
|
|
|
binaryNativeCode # "geometry3d" bundled libraries
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.bsd3;
|
|
|
|
homepage = "http://www.neuron.yale.edu/neuron";
|
|
|
|
maintainers = [ maintainers.adev ];
|
|
|
|
# source claims it's only tested for x86 and powerpc
|
|
|
|
platforms = platforms.x86_64 ++ platforms.i686;
|
|
|
|
};
|
|
|
|
}
|