1{
2 stdenv,
3 pkgs,
4 lib,
5 fetchurl,
6 gfortran,
7 ncurses,
8 perl,
9 flex,
10 texinfo,
11 qhull,
12 libsndfile,
13 portaudio,
14 libX11,
15 graphicsmagick,
16 pcre2,
17 pkg-config,
18 libGL,
19 libGLU,
20 fltk,
21 # Both are needed for discrete Fourier transform
22 fftw,
23 fftwSinglePrec,
24 zlib,
25 curl,
26 rapidjson,
27 blas,
28 lapack,
29 # These 3 should use the same lapack and blas as the above, see code prepending
30 qrupdate,
31 arpack,
32 suitesparse,
33 # If set to true, the above 5 deps are overridden to use the blas and lapack
34 # with 64 bit indexes support. If all are not compatible, the build will fail.
35 use64BitIdx ? false,
36 libwebp,
37 gl2ps,
38 ghostscript,
39 hdf5,
40 glpk,
41 gnuplot,
42 # - Include support for GNU readline:
43 enableReadline ? true,
44 readline,
45 # - Build Java interface:
46 enableJava ? true,
47 jdk,
48 python3,
49 sundials,
50 # - Packages required for building extra packages.
51 newScope,
52 callPackage,
53 makeSetupHook,
54 makeWrapper,
55 # - Build Octave Qt GUI:
56 enableQt ? false,
57 libsForQt5,
58 libiconv,
59}:
60
61let
62 # Not always evaluated
63 blas' =
64 if use64BitIdx then
65 blas.override {
66 isILP64 = true;
67 }
68 else
69 blas;
70 lapack' =
71 if use64BitIdx then
72 lapack.override {
73 isILP64 = true;
74 }
75 else
76 lapack;
77 qrupdate' = qrupdate.override {
78 # If use64BitIdx is false, this override doesn't evaluate to a new
79 # derivation, as blas and lapack are not overridden.
80 blas = blas';
81 lapack = lapack';
82 };
83 arpack' = arpack.override {
84 blas = blas';
85 lapack = lapack';
86 };
87 # We keep the option to not enable suitesparse support by putting it null
88 suitesparse' =
89 if suitesparse != null then
90 suitesparse.override {
91 blas = blas';
92 lapack = lapack';
93 }
94 else
95 null;
96 # To avoid confusion later in passthru
97 allPkgs = pkgs;
98in
99stdenv.mkDerivation (finalAttrs: {
100 version = "10.2.0";
101 pname = "octave";
102
103 src = fetchurl {
104 url = "mirror://gnu/octave/octave-${finalAttrs.version}.tar.gz";
105 sha256 = "sha256-B/ttkznS81BzXJFnG+jodNFgAYzGtoj579nVWNI39p8=";
106 };
107
108 postPatch = ''
109 patchShebangs --build build-aux/*.pl
110 '';
111
112 buildInputs = [
113 readline
114 ncurses
115 flex
116 qhull
117 graphicsmagick
118 pcre2
119 fltk
120 zlib
121 curl
122 rapidjson
123 blas'
124 lapack'
125 libsndfile
126 fftw
127 fftwSinglePrec
128 portaudio
129 qrupdate'
130 arpack'
131 libwebp
132 gl2ps
133 ghostscript
134 hdf5
135 glpk
136 suitesparse'
137 sundials
138 gnuplot
139 python3
140 ]
141 ++ lib.optionals enableQt [
142 libsForQt5.qtbase
143 libsForQt5.qtsvg
144 libsForQt5.qscintilla
145 ]
146 ++ lib.optionals (enableJava) [
147 jdk
148 ]
149 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
150 libGL
151 libGLU
152 libX11
153 ]
154 ++ lib.optionals stdenv.hostPlatform.isDarwin [
155 libiconv
156 ];
157 nativeBuildInputs = [
158 perl
159 pkg-config
160 gfortran
161 texinfo
162 ]
163 ++ lib.optionals enableQt [
164 libsForQt5.wrapQtAppsHook
165 libsForQt5.qtscript
166 libsForQt5.qttools
167 ];
168
169 doCheck = !stdenv.hostPlatform.isDarwin;
170
171 enableParallelBuilding = true;
172
173 # Fix linker error on Darwin (see https://trac.macports.org/ticket/61865)
174 NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-lobjc";
175
176 # See https://savannah.gnu.org/bugs/?50339
177 F77_INTEGER_8_FLAG = lib.optionalString use64BitIdx "-fdefault-integer-8";
178
179 configureFlags = [
180 "--with-blas=blas"
181 "--with-lapack=lapack"
182 (if use64BitIdx then "--enable-64" else "--disable-64")
183 ]
184 ++ lib.optionals enableReadline [ "--enable-readline" ]
185 ++ lib.optionals stdenv.hostPlatform.isDarwin [ "--with-x=no" ]
186 ++ lib.optionals enableQt [ "--with-qt=5" ];
187
188 # Keep a copy of the octave tests detailed results in the output
189 # derivation, because someone may care
190 postInstall = ''
191 cp test/fntests.log $out/share/octave/octave-${finalAttrs.version}-fntests.log || true
192 '';
193
194 passthru = rec {
195 sitePath = "share/octave/${finalAttrs.version}/site";
196 octPkgsPath = "share/octave/octave_packages";
197 blas = blas';
198 lapack = lapack';
199 qrupdate = qrupdate';
200 arpack = arpack';
201 suitesparse = suitesparse';
202 octavePackages = import ../../../top-level/octave-packages.nix {
203 pkgs = allPkgs;
204 inherit
205 lib
206 stdenv
207 fetchurl
208 newScope
209 ;
210 octave = finalAttrs.finalPackage;
211 };
212 wrapOctave = callPackage ./wrap-octave.nix {
213 octave = finalAttrs.finalPackage;
214 inherit (allPkgs) makeSetupHook makeWrapper;
215 };
216 inherit fftw fftwSinglePrec;
217 inherit portaudio;
218 inherit jdk;
219 python = python3;
220 inherit enableQt enableReadline enableJava;
221 buildEnv = callPackage ./build-env.nix {
222 octave = finalAttrs.finalPackage;
223 inherit wrapOctave;
224 inherit (octavePackages) computeRequiredOctavePackages;
225 };
226 withPackages = import ./with-packages.nix { inherit buildEnv octavePackages; };
227 pkgs = octavePackages;
228 interpreter = "${finalAttrs.finalPackage}/bin/octave";
229 };
230
231 meta = {
232 homepage = "https://www.gnu.org/software/octave/";
233 license = lib.licenses.gpl3Plus;
234 maintainers = with lib.maintainers; [
235 raskin
236 doronbehar
237 ];
238 description = "Scientific Programming Language";
239 };
240})