anchor.diff:      substituteInPlace "$dev/bin/gdbus-codegen" --replace "$out" "$dev"
       sed -i "$dev/bin/glib-gettextize" -e "s|^gettext_dir=.*|gettext_dir=$dev/share/glib-2.0/gettext|"
     ''
  -    # This file is *included* in gtk3 and would introduce runtime reference via __FILE__.
  -    + ''
  -      sed '1i#line 1 "${name}/include/glib-2.0/gobject/gobjectnotifyqueue.c"' \
  -        -i "$dev"/include/glib-2.0/gobject/gobjectnotifyqueue.c
  -    '';
  +  # This file is *included* in gtk3 and would introduce runtime reference via __FILE__.
  +  + ''
  +    sed '1i#line 1 "${name}/include/glib-2.0/gobject/gobjectnotifyqueue.c"' \
  +      -i "$dev"/include/glib-2.0/gobject/gobjectnotifyqueue.c
  +  '';
   
     inherit doCheck;
  -  preCheck = optionalString doCheck
  -    '' export LD_LIBRARY_PATH="$NIX_BUILD_TOP/${name}/glib/.libs:$LD_LIBRARY_PATH"
  -       export TZDIR="${tzdata}/share/zoneinfo"
  -       export XDG_CACHE_HOME="$TMP"
  -       export XDG_RUNTIME_HOME="$TMP"
  -       export HOME="$TMP"
  -       export XDG_DATA_DIRS="${desktop_file_utils}/share:${shared_mime_info}/share"
  -       export G_TEST_DBUS_DAEMON="${dbus_daemon.out}/bin/dbus-daemon"
  +  preCheck = optionalString doCheck ''
  +    export LD_LIBRARY_PATH="$NIX_BUILD_TOP/${name}/glib/.libs:$LD_LIBRARY_PATH"
  +    export TZDIR="${tzdata}/share/zoneinfo"
  +    export XDG_CACHE_HOME="$TMP"
  +    export XDG_RUNTIME_HOME="$TMP"
  +    export HOME="$TMP"
  +    export XDG_DATA_DIRS="${desktop_file_utils}/share:${shared_mime_info}/share"
  +    export G_TEST_DBUS_DAEMON="${dbus_daemon.out}/bin/dbus-daemon"
  +    export PATH="$PATH:$(pwd)/gobject"
  +    echo "PATH=$PATH"
   
  -       substituteInPlace gio/tests/desktop-files/home/applications/epiphany-weather-for-toronto-island-9c6a4e022b17686306243dada811d550d25eb1fb.desktop --replace "Exec=/bin/true" "Exec=${coreutils}/bin/true"
  -       # Needs machine-id, comment the test
  -       sed -e '/\/gdbus\/codegen-peer-to-peer/ s/^\/*/\/\//' -i gio/tests/gdbus-peer.c
  -       sed -e '/g_test_add_func/ s/^\/*/\/\//' -i gio/tests/gdbus-unix-addresses.c
  -       # All gschemas fail to pass the test, upstream bug?
  -       sed -e '/g_test_add_data_func/ s/^\/*/\/\//' -i gio/tests/gschema-compile.c
  -       # Cannot reproduce the failing test_associations on hydra
  -       sed -e '/\/appinfo\/associations/d' -i gio/tests/appinfo.c
  -       # Needed because of libtool wrappers
  -       sed -e '/g_subprocess_launcher_set_environ (launcher, envp);/a g_subprocess_launcher_setenv (launcher, "PATH", g_getenv("PATH"), TRUE);' -i gio/tests/gsubprocess.c
  -    '';
  +    substituteInPlace gio/tests/desktop-files/home/applications/epiphany-weather-for-toronto-island-9c6a4e022b17686306243dada811d550d25eb1fb.desktop \
  +      --replace "Exec=/bin/true" "Exec=${coreutils}/bin/true"
  +    # Needs machine-id, comment the test
  +    sed -e '/\/gdbus\/codegen-peer-to-peer/ s/^\/*/\/\//' -i gio/tests/gdbus-peer.c
  +    sed -e '/g_test_add_func/ s/^\/*/\/\//' -i gio/tests/gdbus-unix-addresses.c
  +    # All gschemas fail to pass the test, upstream bug?
  +    sed -e '/g_test_add_data_func/ s/^\/*/\/\//' -i gio/tests/gschema-compile.c
  +    # Cannot reproduce the failing test_associations on hydra
  +    sed -e '/\/appinfo\/associations/d' -i gio/tests/appinfo.c
  +    # Needed because of libtool wrappers
  +    sed -e '/g_subprocess_launcher_set_environ (launcher, envp);/a g_subprocess_launcher_setenv (launcher, "PATH", g_getenv("PATH"), TRUE);' -i gio/tests/gsubprocess.c
  +  '';
   
     passthru = {
        gioModuleDir = "lib/gio/modules";
  
positive.code:     ln -sr -t "''${!outputInclude}/include/" "''${!outputInclude}"/lib/*/include/* 2>/dev/null || true
    '';
  
    ver_maj = "2.52";
    ver_min = "3";
  in
  
  stdenv.mkDerivation rec {
  
negative.code:     ++ optional (stdenv.isFreeBSD || stdenv.isSunOS) "--with-libiconv=gnu"
      ++ optional stdenv.isSunOS "--disable-dtrace";
  
    NIX_CFLAGS_COMPILE = optional stdenv.isDarwin "-lintl"
      ++ optional stdenv.isSunOS "-DBSD_COMP";
  
    preConfigure = optionalString stdenv.isSunOS ''
      sed -i -e 's|inotify.h|foobar-inotify.h|g' configure
    '';
  
    postConfigure = ''
      patchShebangs ./gobject/
    '';
  
    LIBELF_CFLAGS = optional stdenv.isFreeBSD "-I${libelf}";
    LIBELF_LIBS = optional stdenv.isFreeBSD "-L${libelf} -lelf";
  
    preBuild = optionalString stdenv.isDarwin ''
      export MACOSX_DEPLOYMENT_TARGET=
    '';
  
    enableParallelBuilding = true;
    DETERMINISTIC_BUILD = 1;
  