mlterm: enable to configure many build features declaratively

This commit is contained in:
Doron Behar 2023-04-14 22:49:24 +03:00
parent a4f65246a0
commit 66d6ebe593

View File

@ -1,13 +1,98 @@
{ stdenv, lib, fetchFromGitHub, pkg-config, autoconf, makeDesktopItem, nixosTests
, libX11, gdk-pixbuf, cairo, libXft, gtk3, vte
, harfbuzz #substituting glyphs with opentype fonts
, fribidi, m17n_lib #bidi and encoding
{ stdenv
, lib
, fetchFromGitHub
, pkg-config
, autoconf
, makeDesktopItem
, nixosTests
, vte
, harfbuzz # can be replaced with libotf
, fribidi
, m17n_lib
, libssh2 #build-in ssh
, fcitx5, fcitx5-gtk, ibus, uim #IME
, fcitx5
, fcitx5-gtk
, ibus
, uim #IME
, wrapGAppsHook #color picker in mlconfig
, gdk-pixbuf
, gtk3
, gtk ? gtk3
# List of gui libraries to use. According to `./configure --help` ran on
# release 3.9.3, options are: (xlib|win32|fb|quartz|console|wayland|sdl2|beos)
, enableGuis ? {
xlib = enableX11;
fb = stdenv.isLinux;
quartz = stdenv.isDarwin;
wayland = stdenv.isLinux;
sdl2 = true;
}
, libxkbcommon
, wayland # for the "wayland" --with-gui option
, SDL2 # for the "sdl" --with-gui option
# List of typing engines, the default list enables compiling all of the
# available ones, as recorded on release 3.9.3
, enableTypeEngines ? {
xcore = false; # Considered legacy
xft = enableX11;
cairo = true;
}
, libX11
, libXft
, cairo
# List of external tools to create, this default list includes all default
# tools, as recorded on release 3.9.3.
, enableTools ? {
mlclient = true;
mlconfig = true;
mlcc = true;
mlterm-menu = true;
# Note that according to upstream's ./configure script, to disable
# mlimgloader you have to disable _all_ tools. See:
# https://github.com/arakiken/mlterm/issues/69
mlimgloader = true;
registobmp = true;
mlfc = true;
}
# Whether to enable the X window system
, enableX11 ? stdenv.isLinux
# Most of the input methods and other build features are enabled by default,
# the following attribute set can be used to disable some of them. It's parsed
# when we set `configureFlags`. If you find other configure Flags that require
# dependencies, it'd be nice to make that contribution here.
, enableFeatures ? {
uim = !stdenv.isDarwin;
ibus = !stdenv.isDarwin;
fcitx = !stdenv.isDarwin;
m17n = !stdenv.isDarwin;
ssh2 = true;
bidi = true;
# Open Type layout support, (substituting glyphs with opentype fonts)
otl = true;
}
# Configure the Exec directive in the generated .desktop file
, desktopBinary ? (
if enableGuis.xlib then
"mlterm"
else if enableGuis.wayland then
"mlterm-wl"
else if enableGuis.sdl2 then
"mlterm-sdl2"
else
throw "mlterm: couldn't figure out what desktopBinary to use."
)
}:
stdenv.mkDerivation rec {
let
# Returns a --with-feature=<comma separated string list of all `true`
# attributes>, or `--without-feature` if all attributes are false or don't
# exist. Used later in configureFlags
withFeaturesList = featureName: attrset: let
commaSepList = lib.concatStringsSep "," (builtins.attrNames (lib.filterAttrs (n: v: v) attrset));
in
lib.withFeatureAs (commaSepList != "") featureName commaSepList
;
in stdenv.mkDerivation rec {
pname = "mlterm";
version = "3.9.3";
@ -18,25 +103,41 @@ stdenv.mkDerivation rec {
sha256 = "sha256-gfs5cdwUUwSBWwJJSaxrQGWJvLkI27RMlk5QvDALEDg=";
};
nativeBuildInputs = [ pkg-config autoconf wrapGAppsHook ];
nativeBuildInputs = [
pkg-config
autoconf
] ++ lib.optionals enableTools.mlconfig [
wrapGAppsHook
];
buildInputs = [
libX11
gdk-pixbuf.dev
cairo
libXft
gtk3
harfbuzz
fribidi
gtk
vte
gdk-pixbuf
] ++ lib.optionals enableTypeEngines.xcore [
libX11
] ++ lib.optionals enableTypeEngines.xft [
libXft
] ++ lib.optionals enableTypeEngines.cairo [
cairo
] ++ lib.optionals enableGuis.wayland [
libxkbcommon
wayland
] ++ lib.optionals enableGuis.sdl2 [
SDL2
] ++ lib.optionals enableFeatures.otl [
harfbuzz
] ++ lib.optionals enableFeatures.bidi [
fribidi
] ++ lib.optionals enableFeatures.ssh2 [
libssh2
] ++ lib.optionals (!stdenv.isDarwin) [
# Not supported on Darwin
] ++ lib.optionals enableFeatures.m17n [
m17n_lib
] ++ lib.optionals enableFeatures.fcitx [
fcitx5
fcitx5-gtk
] ++ lib.optionals enableFeatures.ibus [
ibus
] ++ lib.optionals enableFeatures.uim [
uim
];
@ -61,20 +162,13 @@ stdenv.mkDerivation rec {
'';
configureFlags = [
"--with-imagelib=gdk-pixbuf" #or mlimgloader depending on your bugs of choice
"--with-type-engines=cairo,xft,xcore"
"--with-gtk=3.0"
"--enable-ind" #indic scripts
"--enable-fribidi" #bidi scripts
"--with-tools=mlclient,mlconfig,mlcc,mlterm-menu,mlimgloader,registobmp,mlfc"
#mlterm-menu and mlconfig depend on enabling gnome.at-spi2-core
#and configuring ~/.mlterm/key correctly.
] ++ lib.optionals (!stdenv.isDarwin) [
"--with-x=yes"
"--with-gui=xlib,fb"
"--enable-m17nlib" #character encodings
] ++ lib.optionals stdenv.isDarwin [
"--with-gui=quartz"
(withFeaturesList "type-engines" enableTypeEngines)
(withFeaturesList "tools" enableTools)
(withFeaturesList "gui" enableGuis)
(lib.withFeature enableX11 "x")
] ++ lib.optionals (gtk != null) [
"--with-gtk=${lib.versions.major gtk.version}.0"
] ++ (lib.mapAttrsToList (n: v: lib.enableFeature v n) enableFeatures) ++ [
];
enableParallelBuilding = true;
@ -91,7 +185,7 @@ stdenv.mkDerivation rec {
desktopItem = makeDesktopItem {
name = "mlterm";
exec = "mlterm %U";
exec = "${desktopBinary} %U";
icon = "mlterm";
type = "Application";
comment = "Multi Lingual TERMinal emulator";
@ -101,7 +195,15 @@ stdenv.mkDerivation rec {
startupNotify = false;
};
passthru.tests.test = nixosTests.terminal-emulators.mlterm;
passthru = {
tests.test = nixosTests.terminal-emulators.mlterm;
inherit
enableTypeEngines
enableTools
enableGuis
enableFeatures
;
};
meta = with lib; {
description = "Multi Lingual TERMinal emulator";
@ -109,5 +211,6 @@ stdenv.mkDerivation rec {
license = licenses.bsd3;
maintainers = with maintainers; [ ramkromberg atemu doronbehar ];
platforms = platforms.all;
mainProgram = desktopBinary;
};
}