Skip to content

Commit

Permalink
Merge pull request #226218 from doronbehar/pkg/mlterm-wayland
Browse files Browse the repository at this point in the history
mlterm: Add support for many build configuration variables
  • Loading branch information
Atemu authored Apr 21, 2023
2 parents 13ea5dc + 52016d5 commit dbc1a5e
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 37 deletions.
172 changes: 137 additions & 35 deletions pkgs/applications/terminal-emulators/mlterm/default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +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
, Cocoa #Darwin
, 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";

Expand All @@ -19,25 +103,41 @@ stdenv.mkDerivation rec {
sha256 = "sha256-gfs5cdwUUwSBWwJJSaxrQGWJvLkI27RMlk5QvDALEDg=";
};

nativeBuildInputs = [ pkg-config autoconf wrapGAppsHook ];
nativeBuildInputs = [
pkg-config
autoconf
] ++ lib.optionals enableTools.mlconfig [
wrapGAppsHook
];
buildInputs = [
gtk
vte
gdk-pixbuf
] ++ lib.optionals enableTypeEngines.xcore [
libX11
gdk-pixbuf.dev
cairo
] ++ lib.optionals enableTypeEngines.xft [
libXft
gtk3
] ++ 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
vte

] ++ 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
];

Expand All @@ -62,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;
Expand All @@ -92,23 +185,32 @@ stdenv.mkDerivation rec {

desktopItem = makeDesktopItem {
name = "mlterm";
exec = "mlterm %U";
exec = "${desktopBinary} %U";
icon = "mlterm";
type = "Application";
comment = "Terminal emulator";
comment = "Multi Lingual TERMinal emulator";
desktopName = "mlterm";
genericName = "Terminal emulator";
categories = [ "Application" "System" "TerminalEmulator" ];
categories = [ "System" "TerminalEmulator" ];
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";
homepage = "https://mlterm.sourceforge.net/";
license = licenses.bsd3;
maintainers = with maintainers; [ ramkromberg atemu ];
maintainers = with maintainers; [ ramkromberg atemu doronbehar ];
platforms = platforms.all;
mainProgram = desktopBinary;
};
}
5 changes: 3 additions & 2 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2575,8 +2575,9 @@ with pkgs;

microcom = callPackage ../applications/terminal-emulators/microcom { };

mlterm = darwin.apple_sdk_11_0.callPackage ../applications/terminal-emulators/mlterm {
inherit (darwin.apple_sdk_11_0.frameworks) Cocoa;
mlterm = darwin.apple_sdk_11_0.callPackage ../applications/terminal-emulators/mlterm { };
mlterm-wayland = mlterm.override {
enableX11 = false;
};

mrxvt = callPackage ../applications/terminal-emulators/mrxvt { };
Expand Down

0 comments on commit dbc1a5e

Please sign in to comment.