summary refs log tree commit diff
path: root/pkgs/applications/misc/grass/default.nix
blob: 6abf6da4a69f6284b7933ae278c0969d70cee3e3 (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
{ config, ... }@a:

# You can set gui by exporting GRASS_GUI=..
# see http://grass.itc.it/gdp/html_grass64/g.gui.html
# defaulting to wxpython because this is used in the manual
let inherit (builtins) getAttr;
    inherit (a.composableDerivation) edf wwf;
    inherit (a.stdenv.lib) maybeAttr optionalString;

    # wrapper for wwf call
    # lib: the lib whose include and lib paths should be passed
    # {}@args: additional args being merged before passing everything to wwf
    wwfp = lib: {name, ...}@args:
      let mbEnable = maybeAttr "enable" {} args;
      in wwf (args // {
      enable =  mbEnable // {
        buildInputs = [ lib ]
          ++ maybeAttr "buildInputs" [] mbEnable;
        configureFlags = [
          "--with-${name}-libs=${lib}/lib"
          "--with-${name}-includes=${lib}/include"
        ] ++ maybeAttr "configureFlags" [] mbEnable;
      };
    });
in
a.composableDerivation.composableDerivation {} (fix: {

  name = "grass-6.4.0RC6";

  buildInputs = [
    # gentoos package depends on gmath ? 
    a.pkgconfig
    a.flex a.bison a.libXmu a.libXext a.libXp a.libX11 a.libXt a.libSM a.libICE
    a.libXpm a.libXaw a.flex a.bison a.gdbm
    a.makeWrapper
  ];

  cfg = {
    _64bitSupport = config.grass."64bitSupport" or true;
    cursesSupport = config.grass.curses or true;
    gdalSupport = config.grass.gdal or true;
    pythonSupport = config.grass.python or true;
    wxwidgetsSupport = config.grass.wxwidgets or true;
    readlineSupport = config.grass.readline or true;
    jpegSupport = config.grass.jpeg or true;
    tiffSupport = config.grass.tiff or true;
    pngSupport = config.grass.png or true;
    tcltkSupport = config.grass.tcltk or true;
    postgresSupport = config.grass.postgres or true;
    mysqlSupport = config.grass.mysql or true;
    sqliteSupport = config.grass.sqlite or true;
    ffmpegSupport = config.grass.ffmpeg or true;
    openglSupport = config.grass.opengl or true;
    odbcSupport = config.grass.odbc or false; # fails to find libodbc - why ?
    fftwSupport = config.grass.fftw or true;
    blasSupport = config.grass.blas or true;
    lapackSupport = config.grass.lapack or true;
    cairoSupport = config.grass.cairo or true;
    motifSupport = config.grass.motif or true;
    freetypeSupport = config.grass.freetype or true;
    projSupport = config.grass.proj or true;
    opendwgSupport = config.grass.dwg or false;
    largefileSupport = config.grass.largefile or true;
  };

  # ?? NLS support:                no
  # ?? GLw support:                no
  # ?? DWG support:                no
  flags = {

    python = {
      configureFlags = [ "--with-python=${a.python}/bin/python-config" ];
      buildInputs = [a.python a.swig];
    };
    
  }
  // edf { name = "_64bit"; feat = "64bit"; }
  // wwfp a.ncurses { name = "curses"; }
  // wwfp a.gdal { name = "gdal"; }
  // wwfp a.wxGTK { name = "wxwidgets"; value = "${a.wxGTK}/bin/wx-config"; }
  // wwfp a.readline { name = "readline"; }
  // wwfp a.libjpeg { name = "jpeg"; }
  // wwfp a.libtiff { name = "tiff"; }
  // wwfp a.libpng { name = "png"; }
  // wwfp a.tk { name = "tcltk"; enable.buildInputs = [ a.tcl ]; }
  // wwfp a.postgresql { name = "postgres"; }
  // wwf {
    name = "mysql";
    enable = {
      buildInputs = [ a.mysql ];
      configureFlags = [
        "--with-mysql-libs=${a.mysql}/lib/mysql"
        "--with-mysql-includes=${a.mysql}/include/mysql"
      ];
    };
  }
  // wwfp a.sqlite { name = "sqlite"; }
  // wwf {
    name = "ffmpeg";
    enable = {
      configureFlags = [
        "--with-ffmpeg-libs=${a.ffmpeg}/lib"
        "--with-ffmpeg-includes=${a.ffmpeg}/include"
      ];
      # is there a nicer way to pass additional include directories?
      # this should work: --with-ffmpeg-includes=/usr/include/lib[av|sw]*
      # I did not try
      preConfigure = ''
        for dir in ${a.ffmpeg}/include/*; do
          if [ -d $dir ]; then
            NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I$dir"
          fi
        done
      '';
      buildInputs = [a.ffmpeg];
    };
  }
  // wwfp a.mesa { name = "opengl"; }
  // wwfp a.unixODBC { name = "odbc"; }
  // wwfp a.fftw { name = "fftw"; }
  // wwf {
    name = "blas"; 
    enable.configureFlags = [ "--with-blas-libs=${a.blas}/lib" ];
  }
  // wwf {
    name = "lapack";
    enable.configureFlags = [ "--with-lapack-libs=${a.liblapack}/lib" ];
  }
  // wwfp a.cairo {
    name = "cairo";
    enable.buildInputs = [ a.fontconfig a.libXrender ];
  }
  // wwfp a.motif { name = "motif"; }
  // wwf {
    name="freetype";
    enable = {
      buildInputs = [ a.freetype ];
      configureFlags = [
        "--with-freetype-libs=${a.freetype}/lib"
        "--with-freetype-includes=${a.freetype}/include/freetype2"
      ];
    };
  }
  // wwfp a.proj { name = "proj"; enable.configureFlags = [ "--with-proj-share=${a.proj}/share"]; }
  // wwfp a.opendwg { name = "opendwg"; }
  // edf {
    name = "largefile";
  };
  /* ?
  // wwf {
    name = "x";
    enable.buildInputs = [];
  };
  */

  src = a.fetchurl {
    url = "http://grass.itc.it/grass64/source/grass-6.4.0RC6.tar.gz";
    sha256 = "043cxa224rd4q1x2mq7sl7ylnxv2vvb4k8laycgcjnp60nzhlmaz";
  };

  postInstall = ''
    e=$(echo $out/bin/grass*)
    mv $out/bin/{,.}$(basename $e)
    cat >> $e << EOF
    #!/bin/sh
    export PATH=${a.python}/bin:\$PATH
    export GRASS_WISH=\${a.tk}/bin/wish
    export GRASS_GUI=\''${GRASS_GUI:-wxpython}
    export SHELL=/bin/sh
    ${optionalString fix.fixed.cfg.wxwidgetsSupport ''export PYTHONPATH=\$PYTHONPATH\''${PYTHONPATH:+:}:$(toPythonPath ${a.wxPython})''}
    exec $out/bin/.$(basename $e)
    EOF
    chmod +x $e
  '';

  meta = {
    description = "free Geographic Information System (GIS) software used for geospatial data management and analysis, image processing, graphics/maps production, spatial modeling, and visualization";
    homepage = http://grass.itc.it/index.php;
    license = [ "GPL" ];
  };

})