2021-09-03 00:41:43 +02:00
|
|
|
{ emacs, vtermModule, nixpkgs-unstable, ... }:
|
|
|
|
final: prev:
|
2021-09-14 21:57:44 +02:00
|
|
|
|
|
|
|
with prev.lib;
|
2021-09-03 00:41:43 +02:00
|
|
|
let
|
2021-09-14 21:57:44 +02:00
|
|
|
inherit (prev) callPackage stdenv;
|
|
|
|
|
|
|
|
hunspellWithDicts = cfg:
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = (appendToName "with-dicts" cfg.hunspell.package).name;
|
|
|
|
buildInputs = [ prev.makeWrapper ];
|
|
|
|
buildCommand = ''
|
|
|
|
makeWrapper ${cfg.hunspell.package.bin}/bin/hunspell $out/bin/hunspell --prefix DICPATH : ${makeSearchPath "share/hunspell" cfg.hunspell.dictionaries}
|
|
|
|
'';
|
|
|
|
meta = removeAttrs cfg.hunspell.package.meta ["outputsToInstall"];
|
|
|
|
};
|
2021-09-03 00:41:43 +02:00
|
|
|
in
|
|
|
|
{
|
|
|
|
magic_rb = prev.magic_rb or {} // {
|
|
|
|
libvterm-emacs = stdenv.mkDerivation {
|
|
|
|
name = "vterm-emacs";
|
|
|
|
src = vtermModule;
|
|
|
|
buildInputs = with prev; [ cmake libtool glib.dev libvterm-neovim ];
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DEMACS_SOURCE=${emacs}"
|
|
|
|
"-DUSE_SYSTEM_LIBVTERM=ON"
|
|
|
|
];
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/lib
|
|
|
|
install ../vterm-module.so $out/lib
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
emacs = callPackage
|
2021-09-07 07:55:53 +02:00
|
|
|
(module:
|
|
|
|
let
|
2021-09-14 21:57:44 +02:00
|
|
|
mkPkgOption = name:
|
2021-09-07 07:55:53 +02:00
|
|
|
mkOption {
|
|
|
|
description = "`${name}` package.";
|
|
|
|
default = prev.${name};
|
|
|
|
type = types.package;
|
|
|
|
};
|
|
|
|
|
2021-09-14 21:57:44 +02:00
|
|
|
evaled = evalModules
|
2021-09-07 07:55:53 +02:00
|
|
|
{ modules = [ module ] ++ singleton
|
|
|
|
({ config, ... }:
|
|
|
|
{ options = {
|
|
|
|
pkgs = {
|
|
|
|
giflib = mkPkgOption "giflib";
|
|
|
|
librsvg = mkPkgOption "librsvg";
|
|
|
|
glib-networking = mkPkgOption "glib-networking";
|
|
|
|
webkitgtk = mkPkgOption "webkitgtk";
|
|
|
|
xorg = mkOption {
|
|
|
|
description = "`xorg` package set.";
|
|
|
|
default = prev.xorg;
|
|
|
|
type = with types; attrsOf package;
|
|
|
|
};
|
|
|
|
makeWrapper = mkPkgOption "makeWrapper";
|
|
|
|
libvterm-emacs = mkOption {
|
|
|
|
description = "`libvterm-emacs` package.";
|
|
|
|
default = final.magic_rb.libvterm-emacs;
|
|
|
|
type = types.package;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
march = mkOption {
|
|
|
|
description = ''
|
|
|
|
Optimize for a specific architecture.
|
|
|
|
'';
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
additionalPackages = mkOption {
|
|
|
|
description = ''
|
|
|
|
Additional packages to add statically to the Emacs closure, requires a
|
|
|
|
restart of Emacs for changes to take effect.
|
|
|
|
'';
|
2021-09-14 21:57:44 +02:00
|
|
|
type = with types; listOf package;
|
2021-09-07 07:55:53 +02:00
|
|
|
default = [];
|
|
|
|
};
|
|
|
|
|
2021-11-08 22:01:07 +01:00
|
|
|
environment = mkOption {
|
|
|
|
description = ''
|
|
|
|
Set additional environment variables.
|
|
|
|
'';
|
|
|
|
type = with types; attrsOf (oneOf [ str path ]);
|
|
|
|
default = {};
|
|
|
|
};
|
|
|
|
|
2021-09-14 21:57:44 +02:00
|
|
|
hunspell = {
|
|
|
|
enable = mkEnableOption "Enable hunspell and dictionaries";
|
|
|
|
package = mkPkgOption "hunspell";
|
|
|
|
dictionaries = mkOption {
|
|
|
|
description = ''
|
|
|
|
Dictionaries included with Hunspell.
|
|
|
|
'';
|
|
|
|
type = with types; listOf package;
|
|
|
|
default = [];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-09-07 07:55:53 +02:00
|
|
|
output = {
|
|
|
|
base = mkOption {
|
|
|
|
readOnly = true;
|
|
|
|
type = types.package;
|
|
|
|
description = ''
|
|
|
|
Emacs base output without additional packages available.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
bundle = mkOption {
|
|
|
|
readOnly = true;
|
|
|
|
type = types.package;
|
|
|
|
description = ''
|
|
|
|
Emacs bundle with additional packages.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = {
|
2021-09-14 21:57:44 +02:00
|
|
|
additionalPackages =
|
|
|
|
(optional config.hunspell.enable (hunspellWithDicts config));
|
|
|
|
|
2021-09-07 07:55:53 +02:00
|
|
|
output.base =
|
|
|
|
(callPackage (import "${nixpkgs-unstable}/pkgs/applications/editors/emacs/generic.nix"
|
|
|
|
{
|
|
|
|
version = "28";
|
|
|
|
sha256 = lib.fakeSha256;
|
|
|
|
patches = _: [];
|
|
|
|
})
|
|
|
|
{
|
|
|
|
withX = false;
|
|
|
|
withGTK3 = false;
|
|
|
|
nativeComp = true;
|
|
|
|
srcRepo = true;
|
|
|
|
|
|
|
|
libXaw = null;
|
|
|
|
Xaw3d = null;
|
|
|
|
gconf = null;
|
|
|
|
alsa-lib = null;
|
|
|
|
acl = null;
|
|
|
|
gpm = null;
|
|
|
|
|
|
|
|
AppKit = null;
|
|
|
|
GSS = null;
|
|
|
|
ImageIO = null;
|
|
|
|
sigtool = null;
|
|
|
|
}).overrideAttrs
|
|
|
|
(old:
|
|
|
|
{
|
|
|
|
src = emacs;
|
|
|
|
|
|
|
|
configureFlags =
|
|
|
|
[ "--disable-build-details"
|
|
|
|
"--with-native-compilation"
|
|
|
|
|
|
|
|
"--with-xpm=yes" "--with-jpeg=yes" "--with-png=yes" "--with-gif=yes" "--with-tiff=yes"
|
|
|
|
"--with-json=yes"
|
|
|
|
"--with-cairo" "--without-x" "--with-pgtk"
|
|
|
|
"--with-modules"
|
|
|
|
"--prefix=\${out}"
|
|
|
|
];
|
|
|
|
|
|
|
|
NIX_CFLAGS_COMPILE="-O2 -pipe ${optionalString (config.march != null) ("-march=" + config.march)}";
|
|
|
|
|
|
|
|
buildInputs =
|
|
|
|
old.buildInputs
|
|
|
|
++ (with config.pkgs; [ giflib librsvg glib-networking webkitgtk xorg.libXpm ]);
|
|
|
|
|
|
|
|
makeFlags = old.makeFlags or [] ++
|
|
|
|
[ "NATIVE_FULL_AOT=1"
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
|
|
|
output.bundle = with config.pkgs; with config.output;
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
inherit (base) pname version;
|
|
|
|
|
|
|
|
phases = [ "buildPhase" ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
mkdir -p $out
|
|
|
|
${xorg.lndir}/bin/lndir -silent ${base} $out
|
|
|
|
wrapProgram $out/bin/emacs \
|
|
|
|
--prefix EMACSLOADPATH : ${libvterm-emacs}/lib: \
|
2021-11-08 22:01:07 +01:00
|
|
|
--prefix PATH : ${makeBinPath config.additionalPackages} \
|
|
|
|
${concatStringsSep " " (mapAttrsToList (k: v: "--set " + k + " " + v) config.environment)}
|
2021-09-07 07:55:53 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
};
|
|
|
|
in
|
|
|
|
evaled.config.output)
|
2021-09-03 00:41:43 +02:00
|
|
|
{};
|
|
|
|
};
|
|
|
|
}
|