<commit_before>{ stdenv, fetchurl, fetchpatch, gdal, cmake, qt4, flex, bison, proj, geos, xlibsWrapper, sqlite, gsl
, qwt, fcgi, python2Packages, libspatialindex, libspatialite, qscintilla, postgresql, makeWrapper
, qjson, qca2, txt2tags, openssl, darwin, pkgconfig
, withGrass ? false, grass, IOKit, ApplicationServices
}:

stdenv.mkDerivation rec {
  name = "qgis-2.18.17";

  buildInputs = [ gdal qt4 flex openssl bison proj geos xlibsWrapper sqlite gsl qwt qscintilla
    fcgi libspatialindex libspatialite postgresql qjson qca2 txt2tags pkgconfig ]
  ++
    (stdenv.lib.optionals stdenv.isDarwin [IOKit ApplicationServices])
  ++
    (stdenv.lib.optional withGrass grass) ++
    (stdenv.lib.optional (stdenv.isDarwin && withGrass) darwin.apple_sdk.libs.utmp) ++
    (with python2Packages; [ jinja2 numpy psycopg2 pygments requests python2Packages.qscintilla sip ]);

  nativeBuildInputs = [ cmake makeWrapper pkgconfig ];

  # `make -f src/providers/wms/CMakeFiles/wmsprovider_a.dir/build.make src/providers/wms/CMakeFiles/wmsprovider_a.dir/qgswmssourceselect.cpp.o`:
  # fatal error: ui_qgsdelimitedtextsourceselectbase.h: No such file or directory
  enableParallelBuilding = false;

  preConfigure = ''
    NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE $(pkg-config --cflags libspatialindex)"
  '';

  # To handle the lack of 'local' RPATH; required, as they call one of
  # their built binaries requiring their libs, in the build process.
  preBuild = ''
    export LD_LIBRARY_PATH=`pwd`/output/lib:${stdenv.lib.makeLibraryPath [ openssl ]}:$LD_LIBRARY_PATH
  '';

  src = fetchurl {
    url = "http://qgis.org/downloads/${name}.tar.bz2";
    sha256 = "<KEY>";
  };

  # CMAKE_FIND_FRAMEWORK=never stops the installer choosing system
  # installed frameworks
  # QGIS_MACAPP_BUNDLE=0 stops the installer copying the Qt binaries into the
  # installation which causes havoc
  # Building RelWithDebInfo allows QGIS_DEBUG to print debugging information
  cmakeFlags = stdenv.lib.optional withGrass "-DGRASS_PREFIX7=${grass}/${grass.name}"
               ++ stdenv.lib.optional stdenv.isDarwin
                    (["-DCMAKE_FIND_FRAMEWORK=never"]
                      ++ ["-DQGIS_MACAPP_BUNDLE=0"]);
#                     ++ ["-DCMAKE_BUILD_TYPE=RelWithDebInfo"];



  postInstall =
    (stdenv.lib.optionalString stdenv.isLinux ''
          wrapProgram $out/bin/qgis \
            --set PYTHONPATH $PYTHONPATH \
            --prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ openssl ]}
          '') +
    (stdenv.lib.optionalString stdenv.isDarwin ''
      # Necessary for QGIS to find the correct default GRASS path
      ${stdenv.lib.optionalString withGrass "ln -sf ${grass} $out/QGIS.app/Contents/MacOS/grass"}
      for file in $(find $out -type f -name "QGIS"); do
        wrapProgram "$file" \
          --prefix DYLD_LIBRARY_PATH : "${qwt}/lib" \
          --prefix DYLD_LIBRARY_PATH : "${qscintilla}/lib" \
          ${stdenv.lib.optionalString withGrass "--prefix PATH : ${grass}/bin"} \
          --set PYTHONPATH $PYTHONPATH
      done
      mkdir -p $out/bin
      ln -s $out/QGIS.app/Contents/MacOS/QGIS $out/bin/qgis
      '');

  meta = {
    description = "User friendly Open Source Geographic Information System";
    homepage = http://www.qgis.org;
    license = stdenv.lib.licenses.gpl2Plus;
    platforms = with stdenv.lib.platforms; unix;
    maintainers = with stdenv.lib.maintainers; [viric];
  };
}<commit_msg>QGIS: Allow plugins to find GDAL tools by looking on PATH<commit_after>{ stdenv, fetchurl, fetchpatch, gdal, cmake, qt4, flex, bison, proj, geos, xlibsWrapper, sqlite, gsl
, qwt, fcgi, python2Packages, libspatialindex, libspatialite, qscintilla, postgresql, makeWrapper
, qjson, qca2, txt2tags, openssl, darwin, pkgconfig
, withGrass ? false, grass, IOKit, ApplicationServices
}:

stdenv.mkDerivation rec {
  name = "qgis-2.18.17";

  buildInputs = [ gdal qt4 flex openssl bison proj geos xlibsWrapper sqlite gsl qwt qscintilla
    fcgi libspatialindex libspatialite postgresql qjson qca2 txt2tags pkgconfig ]
  ++
    (stdenv.lib.optionals stdenv.isDarwin [IOKit ApplicationServices])
  ++
    (stdenv.lib.optional withGrass grass) ++
    (stdenv.lib.optional (stdenv.isDarwin && withGrass) darwin.apple_sdk.libs.utmp) ++
    (with python2Packages; [ jinja2 numpy psycopg2 pygments requests python2Packages.qscintilla sip ]);

  nativeBuildInputs = [ cmake makeWrapper pkgconfig ];

  # `make -f src/providers/wms/CMakeFiles/wmsprovider_a.dir/build.make src/providers/wms/CMakeFiles/wmsprovider_a.dir/qgswmssourceselect.cpp.o`:
  # fatal error: ui_qgsdelimitedtextsourceselectbase.h: No such file or directory
  enableParallelBuilding = false;

  preConfigure = ''
    NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE $(pkg-config --cflags libspatialindex)"
  '';

  # To handle the lack of 'local' RPATH; required, as they call one of
  # their built binaries requiring their libs, in the build process.
  preBuild = ''
    export LD_LIBRARY_PATH=`pwd`/output/lib:${stdenv.lib.makeLibraryPath [ openssl ]}:$LD_LIBRARY_PATH
  '';

  src = fetchurl {
    url = "http://qgis.org/downloads/${name}.tar.bz2";
    sha256 = "1nxwl5lwibbiz9v3qaw3px7iyxg113zr4j8d99yj07mhk2ap082y";
  };

  # CMAKE_FIND_FRAMEWORK=never stops the installer choosing system
  # installed frameworks
  # QGIS_MACAPP_BUNDLE=0 stops the installer copying the Qt binaries into the
  # installation which causes havoc
  # Building RelWithDebInfo allows QGIS_DEBUG to print debugging information
  cmakeFlags = stdenv.lib.optional withGrass "-DGRASS_PREFIX7=${grass}/${grass.name}"
               ++ stdenv.lib.optional stdenv.isDarwin
                    (["-DCMAKE_FIND_FRAMEWORK=never"]
                      ++ ["-DQGIS_MACAPP_BUNDLE=0"]);
#                     ++ ["-DCMAKE_BUILD_TYPE=RelWithDebInfo"];



  postInstall =
    (stdenv.lib.optionalString stdenv.isLinux ''
          wrapProgram $out/bin/qgis \
            --set PYTHONPATH $PYTHONPATH \
            --prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ openssl ]}
          '') +
    (stdenv.lib.optionalString stdenv.isDarwin ''
      # Necessary for QGIS to find the correct default GRASS path
      # Plugins look for gdal tools like deminfo on the PATH
      ${stdenv.lib.optionalString withGrass "ln -sf ${grass} $out/QGIS.app/Contents/MacOS/grass"}
      for file in $(find $out -type f -name "QGIS"); do
        wrapProgram "$file" \
          --prefix DYLD_LIBRARY_PATH : "${qwt}/lib" \
          --prefix DYLD_LIBRARY_PATH : "${qscintilla}/lib" \
          --prefix PATH : "${gdal}/bin" \
          ${stdenv.lib.optionalString withGrass "--prefix PATH : ${grass}/bin"} \
          --set PYTHONPATH $PYTHONPATH
      done
      mkdir -p $out/bin
      ln -s $out/QGIS.app/Contents/MacOS/QGIS $out/bin/qgis
      '');

  meta = {
    description = "User friendly Open Source Geographic Information System";
    homepage = http://www.qgis.org;
    license = stdenv.lib.licenses.gpl2Plus;
    platforms = with stdenv.lib.platforms; unix;
    maintainers = with stdenv.lib.maintainers; [viric];
  };
}
{'fraction_non_alphanumeric': 0.11296243998870376, 'fraction_numerical': 0.00946060434905394, 'mean_word_length': 3.3374157991426823, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2257071', 'n_tokens_mistral': 2583, 'n_tokens_neox': 2421, 'n_words': 541}