about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/interpreters/gnudatalanguage/default.nix
blob: 54b5c5898c87f49682dc654e23d090aedb26ec4c (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
{ stdenv
, lib
, fetchFromGitHub
, cmake
, wrapGAppsHook
, readline
, ncurses
, zlib
, gsl
, openmp
, graphicsmagick
, fftw
, fftwFloat
, fftwLongDouble
, proj
, shapelib
, expat
, udunits
, eigen
, pslib
, libpng
, plplot
, libtiff
, libgeotiff
, libjpeg
  # eccodes is broken on darwin
, enableGRIB ? stdenv.isLinux
, eccodes
, enableGLPK ? stdenv.isLinux
, glpk
  # We enable it in hdf4 and use libtirpc as a dependency here from the passthru
  # of hdf4
, enableLibtirpc ? stdenv.isLinux
, libtirpc
, python3
, enableMPI ? (stdenv.isLinux || stdenv.isDarwin)
  # Choose MPICH over OpenMPI because it currently builds on AArch and Darwin
, mpi
  # Unfree optional dependency for hdf4 and hdf5
, enableSzip ? false
, szip
, enableHDF4 ? true
, hdf4
, hdf4-forced ? null
, enableHDF5 ? true
  # HDF5 format version (API version) 1.10 and 1.12 is not fully compatible
  # Specify if the API version should default to 1.10
  # netcdf currently depends on hdf5 with `usev110Api=true`
  # If you wish to use HDF5 API version 1.12 (`useHdf5v110Api=false`),
  # you will need to turn NetCDF off.
, useHdf5v110Api ? true
, hdf5
, hdf5-forced ? null
, enableNetCDF ? true
, netcdf
, netcdf-forced ? null
, plplot-forced ? null
  # wxWidgets is preferred over X11 for this project but we only have it on Linux
  # and Darwin.
, enableWX ? (stdenv.isLinux || stdenv.isDarwin)
, wxGTK32
, Cocoa
  # X11: OFF by default for platform consistency. Use X where WX is not available
, enableXWin ? (!stdenv.isLinux && !stdenv.isDarwin)
}:

let
  hdf4-custom =
    if hdf4-forced != null
    then hdf4-forced
    else
      hdf4.override {
        uselibtirpc = enableLibtirpc;
        szipSupport = enableSzip;
        inherit szip;
      };
  hdf5-custom =
    if hdf5-forced != null
    then hdf5-forced
    else
      hdf5.override ({
        usev110Api = useHdf5v110Api;
        mpiSupport = enableMPI;
        inherit mpi;
        szipSupport = enableSzip;
        inherit szip;
      } // lib.optionalAttrs enableMPI {
        cppSupport = false;
      });
  netcdf-custom =
    if netcdf-forced != null
    then netcdf-forced
    else
      netcdf.override {
        hdf5 = hdf5-custom;
      };
  enablePlplotDrivers = enableWX || enableXWin;
  plplot-with-drivers =
    if plplot-forced != null
    then plplot-forced
    else
      plplot.override {
        inherit
          enableWX
          enableXWin
          ;
      };
in
stdenv.mkDerivation rec {
  pname = "gnudatalanguage";
  version = "1.0.1";

  src = fetchFromGitHub {
    owner = pname;
    repo = "gdl";
    rev = "v${version}";
    sha256 = "sha256-IrCLL8MQp0SkWj7sbfZlma5FrnMbgdl4E/1nPGy0Y60=";
  };

  buildInputs = [
    readline
    ncurses
    zlib
    gsl
    openmp
    graphicsmagick
    fftw
    fftwFloat
    fftwLongDouble
    proj
    shapelib
    expat
    mpi
    udunits
    eigen
    pslib
    libpng
    libtiff
    libgeotiff
    libjpeg
    hdf4-custom
    hdf5-custom
    netcdf-custom
    plplot-with-drivers
  ] ++ lib.optional enableXWin plplot-with-drivers.libX11
  ++ lib.optional enableGRIB eccodes
  ++ lib.optional enableGLPK glpk
  ++ lib.optional enableWX wxGTK32
  ++ lib.optional (enableWX && stdenv.isDarwin) Cocoa
  ++ lib.optional enableMPI mpi
  ++ lib.optional enableLibtirpc hdf4-custom.libtirpc
  ++ lib.optional enableSzip szip;

  propagatedBuildInputs = [
    (python3.withPackages (ps: with ps; [ numpy ]))
  ];

  nativeBuildInputs = [
    cmake
  ] ++ lib.optional enableWX wrapGAppsHook;

  cmakeFlags = lib.optional (!enableHDF4) "-DHDF=OFF"
    ++ [ (if enableHDF5 then "-DHDF5DIR=${hdf5-custom}" else "-DHDF5=OFF") ]
    ++ lib.optional (!enableNetCDF) "-DNETCDF=OFF"
    ++ lib.optional (!enablePlplotDrivers) "-DINTERACTIVE_GRAPHICS=OFF"
    ++ lib.optional (!enableGRIB) "-DGRIB=OFF"
    ++ lib.optional (!enableGLPK) "-DGLPK=OFF"
    ++ lib.optional (!enableWX) "-DWXWIDGETS=OFF"
    ++ lib.optional enableSzip "-DSZIPDIR=${szip}"
    ++ lib.optionals enableXWin [ "-DX11=ON" "-DX11DIR=${plplot-with-drivers.libX11}" ]
    ++ lib.optionals enableMPI [ "-DMPI=ON" "-DMPIDIR=${mpi}" ];

  # Tests are failing on Hydra:
  # ./src/common/dpycmn.cpp(137): assert ""IsOk()"" failed in GetClientArea(): invalid wxDisplay object
  doCheck = stdenv.isLinux;

  # Opt-out unstable tests
  # https://github.com/gnudatalanguage/gdl/issues/482
  # https://github.com/gnudatalanguage/gdl/issues/1079
  # https://github.com/gnudatalanguage/gdl/issues/460
  preCheck = ''
    checkFlagsArray+=("ARGS=-E '${lib.concatMapStringsSep "|" (test: test + ".pro") [
      "test_byte_conversion"
      "test_bytscl"
      "test_call_external"
      "test_tic_toc"
      "test_timestamp"
    ]}'")
  '';

  passthru = {
    hdf4 = hdf4-custom;
    hdf5 = hdf5-custom;
    netcdf = netcdf-custom;
    plplot = plplot-with-drivers;
    python = python3;
    inherit
      enableMPI
      mpi
      useHdf5v110Api
      enableSzip
      enableWX
      enableXWin
      ;
  };

  meta = with lib; {
    description = "Free incremental compiler of IDL";
    longDescription = ''
      GDL (GNU Data Language) is a free/libre/open source incremental compiler
      compatible with IDL (Interactive Data Language) and to some extent with PV-WAVE.
      GDL is aimed as a drop-in replacement for IDL.
    '';
    homepage = "https://github.com/gnudatalanguage/gdl";
    license = licenses.gpl2Only;
    maintainers = with maintainers; [ ShamrockLee ];
    platforms = platforms.all;
    mainProgram = "gdl";
  };
}