about summary refs log tree commit diff
path: root/pkgs/development/interpreters/octave/default.nix
blob: e221956cf225fb1458b776ce0bd068c86d9cba63 (plain) (blame)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
{ stdenv
, pkgs
, lib
# Note: either stdenv.mkDerivation or, for octaveFull, the qt-5 mkDerivation
# with wrapQtAppsHook (comes from libsForQt5.callPackage)
, mkDerivation
, fetchurl
, gfortran
, ncurses
, perl
, flex
, texinfo
, qhull
, libsndfile
, portaudio
, libX11
, graphicsmagick
, pcre
, pkg-config
, libGL
, libGLU
, fltk
# Both are needed for discrete Fourier transform
, fftw
, fftwSinglePrec
, zlib
, curl
, rapidjson
, blas, lapack
# These two should use the same lapack and blas as the above
, qrupdate, arpack, suitesparse ? null
# If set to true, the above 5 deps are overridden to use the blas and lapack
# with 64 bit indexes support. If all are not compatible, the build will fail.
, use64BitIdx ? false
, libwebp
, gl2ps
, ghostscript ? null
, hdf5 ? null
, glpk ? null
, gnuplot ? null
# - Include support for GNU readline:
, enableReadline ? true
, readline ? null
# - Build Java interface:
, enableJava ? true
, jdk ? null
, python ? null
, overridePlatforms ? null
, sundials ? null
# - Packages required for building extra packages.
, newScope
, callPackage
, makeSetupHook
, makeWrapper
# - Build Octave Qt GUI:
, enableQt ? false
, qtbase ? null
, qtsvg ? null
, qtscript ? null
, qscintilla ? null
, qttools ? null
, libiconv
, darwin
}:

let

  # Not always evaluated
  blas' = if use64BitIdx then
    blas.override {
      isILP64 = true;
    }
  else
    blas
  ;
  lapack' = if use64BitIdx then
    lapack.override {
      isILP64 = true;
    }
  else
    lapack
  ;
  qrupdate' = qrupdate.override {
    # If use64BitIdx is false, this override doesn't evaluate to a new
    # derivation, as blas and lapack are not overridden.
    blas = blas';
    lapack = lapack';
  };
  arpack' = arpack.override {
    blas = blas';
    lapack = lapack';
  };
  # Not always suitesparse is required at all
  suitesparse' = if suitesparse != null then
    suitesparse.override {
      blas = blas';
      lapack = lapack';
    }
  else
    null
  ;

  octavePackages = import ../../../top-level/octave-packages.nix {
    inherit pkgs;
    inherit lib stdenv fetchurl newScope;
    octave = self;
  };

  wrapOctave = callPackage ./wrap-octave.nix {
    octave = self;
    inherit (pkgs) makeSetupHook makeWrapper;
  };

  self = mkDerivation rec {
    version = "7.3.0";
    pname = "octave";

    src = fetchurl {
      url = "mirror://gnu/octave/${pname}-${version}.tar.gz";
      sha256 = "sha256-bhSkZJ1wr0WrZg+Mu/ZFqvHsM/JfiL/aRpfLF+RAxPU=";
    };

    buildInputs = [
      readline
      ncurses
      perl
      flex
      qhull
      graphicsmagick
      pcre
      fltk
      zlib
      curl
      rapidjson
      blas'
      lapack'
      libsndfile
      fftw
      fftwSinglePrec
      portaudio
      qrupdate'
      arpack'
      libwebp
      gl2ps
    ]
    ++ lib.optionals enableQt [
      qtbase
      qtsvg
      qscintilla
    ]
    ++ lib.optionals (ghostscript != null) [ ghostscript ]
    ++ lib.optionals (hdf5 != null) [ hdf5 ]
    ++ lib.optionals (glpk != null) [ glpk ]
    ++ lib.optionals (suitesparse != null) [ suitesparse' ]
    ++ lib.optionals (enableJava) [ jdk ]
    ++ lib.optionals (sundials != null) [ sundials ]
    ++ lib.optionals (gnuplot != null) [ gnuplot ]
    ++ lib.optionals (python != null) [ python ]
    ++ lib.optionals (!stdenv.isDarwin) [ libGL libGLU libX11 ]
    ++ lib.optionals stdenv.isDarwin [
      libiconv
      darwin.apple_sdk.frameworks.Accelerate
      darwin.apple_sdk.frameworks.Cocoa
    ]
    ;
    nativeBuildInputs = [
      pkg-config
      gfortran
      # Listed here as well because it's outputs are split
      fftw
      fftwSinglePrec
      texinfo
    ]
    ++ lib.optionals (sundials != null) [ sundials ]
    ++ lib.optionals enableQt [
      qtscript
      qttools
    ]
    ;

    doCheck = !stdenv.isDarwin;

    enableParallelBuilding = true;

    # Fix linker error on Darwin (see https://trac.macports.org/ticket/61865)
    NIX_LDFLAGS = lib.optionalString stdenv.isDarwin "-lobjc";

    # See https://savannah.gnu.org/bugs/?50339
    F77_INTEGER_8_FLAG = lib.optionalString use64BitIdx "-fdefault-integer-8";

    configureFlags = [
      "--with-blas=blas"
      "--with-lapack=lapack"
      (if use64BitIdx then "--enable-64" else "--disable-64")
    ]
    ++ lib.optionals stdenv.isDarwin [ "--enable-link-all-dependencies" ]
    ++ lib.optionals enableReadline [ "--enable-readline" ]
    ++ lib.optionals stdenv.isDarwin [ "--with-x=no" ]
    ++ lib.optionals enableQt [ "--with-qt=5" ]
    ;

    # Keep a copy of the octave tests detailed results in the output
    # derivation, because someone may care
    postInstall = ''
      cp test/fntests.log $out/share/octave/${pname}-${version}-fntests.log || true
    '';

    passthru = rec {
      sitePath = "share/octave/${version}/site";
      octPkgsPath = "share/octave/octave_packages";
      blas = blas';
      lapack = lapack';
      qrupdate = qrupdate';
      arpack = arpack';
      suitesparse = suitesparse';
      inherit fftw fftwSinglePrec;
      inherit portaudio;
      inherit jdk;
      inherit python;
      inherit enableQt enableReadline enableJava;
      buildEnv = callPackage ./build-env.nix {
        octave = self;
        inherit octavePackages wrapOctave;
        inherit (octavePackages) computeRequiredOctavePackages;
      };
      withPackages = import ./with-packages.nix { inherit buildEnv octavePackages; };
      pkgs = octavePackages;
      interpreter = "${self}/bin/octave";
    };

    meta = {
      homepage = "https://www.gnu.org/software/octave/";
      license = lib.licenses.gpl3Plus;
      maintainers = with lib.maintainers; [ raskin doronbehar ];
      description = "Scientific Programming Language";
      platforms = if overridePlatforms == null then
        (lib.platforms.linux ++ lib.platforms.darwin)
      else overridePlatforms;
    };
  };

in self