anchor.diff:      })
     ];
   
  -  postPatch = lib.optionalString srcRepo ''
  -    rm -fr .git
  -  '';
  +  postPatch = lib.concatStringsSep "\n" [
  +    (lib.optionalString srcRepo ''
  +      rm -fr .git
  +    '')
  +
  +    # Make native compilation work both inside and outside of nix build
  +    (lib.optionalString nativeComp (let
  +      libPath = lib.concatStringsSep ":" [
  +        "${lib.getLib libgccjit}/lib/gcc/${targetPlatform.config}/${libgccjit.version}"
  +        "${lib.getLib stdenv.cc.cc}/lib"
  +        "${lib.getLib stdenv.glibc}/lib"
  +      ];
  +    in ''
  +      substituteInPlace lisp/emacs-lisp/comp.el --replace \
  +        "(defcustom comp-async-env-modifier-form nil" \
  +        "(defcustom comp-async-env-modifier-form '((setenv \"LIBRARY_PATH\" (string-join (seq-filter (lambda (v) (null (eq v nil))) (list (getenv \"LIBRARY_PATH\") \"${libPath}\")) \":\")))"
  +
  +    ''))
  +
  +    ""
  +  ];
   
     CFLAGS = "-DMAC_OS_X_VERSION_MAX_ALLOWED=101200";
   
  -  nativeBuildInputs = [ pkgconfig ]
  +  LIBRARY_PATH = if nativeComp then "${lib.getLib stdenv.cc.libc}/lib" else "";
  +
  +  nativeBuildInputs = [ pkgconfig makeWrapper ]
       ++ lib.optionals srcRepo [ autoconf automake texinfo ]
       ++ lib.optional (withX && (withGTK3 || withXwidgets)) wrapGAppsHook;
   
     buildInputs =
  -    [ ncurses gconf libxml2 gnutls alsaLib acl gpm gettext ]
       [ ncurses gconf libxml2 gnutls alsaLib acl gpm gettext jansson harfbuzz.dev ]
       ++ lib.optionals stdenv.isLinux [ dbus libselinux systemd ]
       ++ lib.optionals withX
  
positive.code:     ++ lib.optionals (withX && withGTK3) [ gtk3-x11 gsettings-desktop-schemas ]
      ++ lib.optional (stdenv.isDarwin && withX) cairo
      ++ lib.optionals (withX && withXwidgets) [ webkitgtk glib-networking ]
      ++ lib.optionals withNS [ AppKit GSS ImageIO ];
  
    hardeningDisable = [ "format" ];
  
  
negative.code: , withCsrc ? true
  , srcRepo ? false, autoconf ? null, automake ? null, texinfo ? null
  , siteStart ? ./site-start.el
  , nativeComp ? false
  , toolkit ? (
    if withGTK2 then "gtk2"
    else if withGTK3 then "gtk3"
  