nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 readline,
6 libxext,
7 libxcomposite,
8 libx11,
9 mpi,
10 cmake,
11 bison,
12 flex,
13 git,
14 perl,
15 gsl,
16 xcbuild,
17 python3,
18 useMpi ? false,
19 useIv ? true,
20 useCore ? false,
21 useRx3d ? false,
22}:
23let
24 inherit (lib.lists) optionals;
25 inherit (lib.strings) cmakeBool;
26in
27stdenv.mkDerivation (finalAttrs: {
28 pname = "neuron";
29 version = "8.2.7";
30
31 # format is for pythonModule conversion
32 format = "other";
33
34 nativeBuildInputs = [
35 cmake
36 bison
37 flex
38 git
39 ]
40 ++ optionals useCore [
41 perl
42 gsl
43 ]
44 ++ optionals stdenv.hostPlatform.isDarwin [ xcbuild ];
45
46 buildInputs = optionals useIv [
47 libx11.dev
48 libxcomposite.dev
49 libxext.dev
50 ];
51
52 propagatedBuildInputs = [
53 readline
54 python3
55 python3.pkgs.wheel
56 python3.pkgs.setuptools
57 python3.pkgs.scikit-build
58 python3.pkgs.matplotlib
59 ]
60 ++ optionals useMpi [
61 mpi
62 ]
63 ++ optionals useMpi [
64 python3.pkgs.mpi4py
65 ]
66 ++ optionals useRx3d [
67 python3.pkgs.cython_0 # NOTE: cython<3 is required as of 8.2.7
68 python3.pkgs.numpy
69 ];
70
71 # Patch build shells for cmake (bin, src, cmake) and submodules (external)
72 postPatch = ''
73 patchShebangs ./bin ./src ./external ./cmake
74 substituteInPlace external/coreneuron/extra/nrnivmodl_core_makefile.in \
75 --replace-fail \
76 "DESTDIR =" \
77 "DESTDIR = $out"
78 '';
79
80 cmakeFlags = [
81 (cmakeBool "NRN_ENABLE_INTERVIEWS" useIv)
82 (cmakeBool "NRN_ENABLE_MPI" useMpi)
83 (cmakeBool "NRN_ENABLE_CORENEURON" useCore)
84 (cmakeBool "NRN_ENABLE_RX3D" useRx3d)
85 ];
86
87 postInstall = ''
88 mkdir -p $out/${python3.sitePackages}
89 mv $out/lib/python/* $out/${python3.sitePackages}/
90 rm -rf $out/lib/python build
91 for entry in $out/lib/*.so; do
92 # remove references to build
93 patchelf --set-rpath $(patchelf --print-rpath $entry | tr ':' '\n' | sed '/^\/build/d' | tr '\n' ':') $entry
94 done
95 '';
96
97 src = fetchFromGitHub {
98 owner = "neuronsimulator";
99 repo = "nrn";
100 tag = finalAttrs.version;
101 fetchSubmodules = true;
102 hash = "sha256-dmpx0Wud0IhdFvvTJuW/w1Uq6vFYaNal9n27LAqV1Qc=";
103 };
104
105 meta = {
106 description = "Simulation environment for empirically-based simulations of neurons and networks of neurons";
107 longDescription = ''
108 NEURON is a simulation environment for developing and exercising models of
109 neurons and networks of neurons. It is particularly well-suited to problems where
110 cable properties of cells play an important role, possibly including extracellular
111 potential close to the membrane), and where cell membrane properties are complex,
112 involving many ion-specific channels, ion accumulation, and second messengers
113 '';
114 sourceProvenance = with lib.sourceTypes; [ fromSource ];
115 license = lib.licenses.bsd3;
116 homepage = "http://www.neuron.yale.edu/neuron";
117 maintainers = with lib.maintainers; [
118 adev
119 davidcromp
120 ];
121 platforms = lib.platforms.all;
122 };
123})