Skip to content

Instantly share code, notes, and snippets.

@mjlbach
Last active August 22, 2020 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjlbach/36d350d39a2656933d4c5d1e0dc408e5 to your computer and use it in GitHub Desktop.
Save mjlbach/36d350d39a2656933d4c5d1e0dc408e5 to your computer and use it in GitHub Desktop.
self: super:
let
  libPath = with super; lib.concatStringsSep ":" [
    "${lib.getLib libgccjit}/lib/gcc/${stdenv.targetPlatform.config}/${libgccjit.version}"
    "${lib.getLib stdenv.cc.cc}/lib"
    "${lib.getLib stdenv.glibc}/lib"
  ];
  rev = "b7adb08f960fe6568f702b8f328e65e3833ffc13";
  sha256 = "0p852k5wf8sy9h7x2z6iivf9xnhpy85vly9fn0a1qj2japrhvyr2";
in
let
  emacsGccPGtk = builtins.foldl' (drv: fn: fn drv)
      super.emacs
      [

        (drv: drv.override { srcRepo = true; })

        (
          drv: drv.overrideAttrs (
            old: {
              name = "emacs-pgtk-native-comp";
              version ="28.0.50";
              src = super.fetchFromGitHub {
                owner = "feijfighter";
                repo = "emacs";
                inherit rev sha256;
              };

              configureFlags = old.configureFlags
                ++ ["--with-pgtk"];



              patches = [
                (super.fetchpatch{
                  name="clean-env.patch";
                  url = "https://raw.githubusercontent.com/nix-community/emacs-overlay/master/patches/clean-env.patch";
                  sha256 = "0lx9062iinxccrqmmfvpb85r2kwfpzvpjq8wy8875hvpm15gp1s5";
                })
                (super.fetchpatch{
                  name="tramp-detect-wrapped-gvfsd.patch";
                  url = "https://raw.githubusercontent.com/nix-community/emacs-overlay/master/patches/tramp-detect-wrapped-gvfsd.patch";
                  sha256 = "19nywajnkxjabxnwyp8rgkialyhdpdpy26mxx6ryfl9ddx890rnc";
                }
                )
              ];


              postPatch = old.postPatch + ''
                substituteInPlace lisp/loadup.el \
                --replace '(emacs-repository-get-version)' '"${rev}"' \
                --replace '(emacs-repository-get-branch)' '"master"'
              '';

            }
          )
        )
        (
          drv: drv.override {
              nativeComp = true;
            }
        )
      ];
in {
  emacsGccWrapped = super.symlinkJoin {
    name = "emacsGccWrapped";
    paths = [ emacsGccPGtk ];
    buildInputs = [ super.makeWrapper ];
    postBuild = ''
      wrapProgram $out/bin/emacs \
      --set LIBRARY_PATH ${libPath}
    '';
    meta.platforms = super.stdenv.lib.platforms.linux;
    passthru.nativeComp = true;
    src = emacsGccPGtk.src;
  };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment