anchor.diff:    NIX_CFLAGS_COMPILE =
       # with gcc7 the warnings blow the log over Hydra's limit
       [ "-Wno-expansion-to-defined" "-Wno-unused-local-typedefs" ]
  -    ++ optional stdenv.isLinux "-std=gnu++98" # gnu++ in (Obj)C flags is no good on Darwin
  -    ++ optionals (stdenv.isFreeBSD || stdenv.isDarwin)
  +    ++ lib.optional stdenv.isLinux "-std=gnu++98" # gnu++ in (Obj)C flags is no good on Darwin
  +    ++ lib.optionals (stdenv.isFreeBSD || stdenv.isDarwin)
         [ "-I${glib.dev}/include/glib-2.0" "-I${glib.out}/lib/glib-2.0/include" ]
  -    ++ optional stdenv.isDarwin "-I${libcxx}/include/c++/v1";
  -
  -  NIX_LDFLAGS = optionalString (stdenv.isFreeBSD || stdenv.isDarwin) "-lglib-2.0";
  -
  -  preBuild = optionalString stdenv.isDarwin ''
  +    ++ lib.optional stdenv.isDarwin "-I${libcxx}/include/c++/v1";
  +
  +  NIX_LDFLAGS = lib.optionalString (stdenv.isFreeBSD || stdenv.isDarwin) "-lglib-2.0";
  +
  +  preBuild = lib.optionalString stdenv.isDarwin ''
       # resolve "extra qualification on member" error
       sed -i 's/struct ::TabletProximityRec;/struct TabletProximityRec;/' \
         src/gui/kernel/qt_cocoa_helpers_mac_p.h
  
positive.code: 
        -no-phonon ${if buildWebkit then "" else "-no"}-webkit ${if buildMultimedia then "" else "-no"}-multimedia -audio-backend
        ${if developerBuild then "-developer-build" else ""}
      '' + optionalString stdenv.isDarwin "-platform unsupported/macx-clang-libc++";
  
    propagatedBuildInputs =
      [ libXrender libXrandr libXinerama libXcursor libXext libXfixes libXv libXi
        libSM zlib libpng openssl dbus freetype fontconfig glib ]
          # Qt doesn't directly need GLU (just GL), but many apps use, it's small and doesn't remain a runtime-dep if not used
      ++ optional libGLSupported libGLU
      ++ optional ((buildWebkit || buildMultimedia) && stdenv.isLinux ) alsaLib
      ++ optionals (buildWebkit || buildMultimedia) [ gstreamer gst-plugins-base ];
  
    # The following libraries are only used in plugins
    buildInputs =
      [ cups # Qt dlopen's libcups instead of linking to it
        postgresql sqlite libjpeg libmng libtiff icu ]
      ++ optionals (mysql != null) [ mysql.connector-c ]
      ++ optionals gtkStyle [ gtk2 gdk_pixbuf ]
      ++ optionals stdenv.isDarwin [ cf-private ApplicationServices OpenGL Cocoa AGL libcxx libobjc ];
  
    nativeBuildInputs = [ perl pkgconfig which ];
  
  
negative.code: 
    postInstall = ''
      rm -rf $out/tests
    ''
    # I don't know why it does not install qmake
    + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
      cp bin/qmake* $out/bin
    '';
  
    dontStrip = if stdenv.hostPlatform == stdenv.buildPlatform then null else true;
  
    meta = {
      homepage    = http://qt-project.org/;
      description = "A cross-platform application framework for C++";
      license     = lib.licenses.lgpl21Plus; # or gpl3
      maintainers = with lib.maintainers; [ orivej lovek323 phreedom sander ];
      platforms   = lib.platforms.unix;
    };
  }
  