This repository has been archived by the owner on Jun 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
emacs.nix
86 lines (76 loc) · 2.61 KB
/
emacs.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
let
sources = import ./nix/sources.nix;
nixpkgs = sources."nixpkgs-unstable";
pkgs = import nixpkgs {};
emacs-nativecomp = sources."emacs-nativecomp";
libPath = with pkgs; lib.concatStringsSep ":" [
"${lib.getLib libgccjit}/lib/gcc/${stdenv.targetPlatform.config}/${libgccjit.version}"
"${lib.getLib stdenv.cc.cc}/lib"
"${lib.getLib stdenv.glibc}/lib"
];
emacsGccDarwin = builtins.foldl' (drv: fn: fn drv)
pkgs.emacs
[
(drv: drv.override { srcRepo = true; })
(
drv: drv.overrideAttrs (
old: {
name = "emacsGccDarwin";
version = "28.0.50";
src = pkgs.fetchFromGitHub {
inherit (emacs-nativecomp) owner repo rev sha256;
};
configureFlags = old.configureFlags
++ [ "--with-ns" "--with-native-compilation" "--with-cairo" "--with-harfbuzz" ];
patches = [
(
pkgs.fetchpatch {
name = "tramp-detect-wrapped-gvfsd.patch";
url = "https://raw.githubusercontent.com/nix-community/emacs-overlay/master/patches/tramp-detect-wrapped-gvfsd.patch";
sha256 = "1rvz725697md3ir618kkrccsxzd6n0p8yddq7rsh5jg8dbrvjvcx";
}
)
];
postPatch = old.postPatch + ''
substituteInPlace lisp/loadup.el \
--replace '(emacs-repository-get-version)' '"${emacs-nativecomp.rev}"' \
--replace '(emacs-repository-get-branch)' '"master"'
'';
postInstall = old.postInstall or "" + ''
ln -snf $out/lib/emacs/28.0.50/native-lisp $out/native-lisp
ln -snf $out/lib/emacs/28.0.50/native-lisp $out/Applications/Emacs.app/Contents/native-lisp
cat <<EOF> $out/bin/run-emacs.sh
#!/usr/bin/env bash
set -e
exec $out/bin/emacs-28.0.50 "\$@"
EOF
chmod a+x $out/bin/run-emacs.sh
ln -snf ./run-emacs.sh $out/bin/emacs
'';
}
)
)
(
drv: drv.override {
nativeComp = true;
}
)
];
in
_: _:
{
ci = (import ./nix {}).ci;
inherit emacsGccDarwin;
emacsGccDarwinWrapped = pkgs.symlinkJoin {
name = "emacsGccDarwinWrapped";
paths = [ emacsGccDarwin ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/emacs \
--set LIBRARY_PATH ${libPath}
'';
meta.platforms = pkgs.stdenv.lib.platforms.linux;
passthru.nativeComp = true;
src = emacsGccDarwin.src;
};
}