anchor.diff:      ++ optional (stdenv.isFreeBSD || stdenv.isSunOS) "--with-libiconv=gnu"
       ++ optional stdenv.isSunOS "--disable-dtrace";
   
  -  NIX_CFLAGS_COMPILE = optionalString stdenv.isDarwin " -lintl"
  -    + optionalString stdenv.isSunOS " -DBSD_COMP";
  +  NIX_CFLAGS_COMPILE = optional stdenv.isDarwin "-lintl"
  +    ++ optional stdenv.isSunOS "-DBSD_COMP";
   
  -  preConfigure = if !stdenv.isSunOS then null else
  -    ''
  -      sed -i -e 's|inotify.h|foobar-inotify.h|g' configure
  -    '';
  +  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=
  -    '';
  +  preBuild = optionalString stdenv.isDarwin ''
  +    export MACOSX_DEPLOYMENT_TARGET=
  +  '';
   
     enableParallelBuilding = true;
     DETERMINISTIC_BUILD = 1;
  
positive.code:     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
      '';
  
    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"
  
         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";
  
negative.code:   meta = with stdenv.lib; {
      description = "C library of programming buildings blocks";
      homepage    = https://www.gtk.org/;
      license     = licenses.lgpl21Plus;
      maintainers = with maintainers; [ lovek323 raskin ];
      platforms   = platforms.unix;
  
  