diff options
author | Atemu <atemu.main@gmail.com> | 2023-04-21 13:02:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-21 13:02:54 +0200 |
commit | dbc1a5e832e0b62d8aaf3790c8d6c5e887f6a161 (patch) | |
tree | fa580f4bed7e30c53f5fade9fb8a6e22159a9f49 | |
parent | 13ea5dc163f5abde5ed5954b75179eee7c420a8e (diff) | |
parent | 52016d5cf70bdf0950349f64f9176a8113dc8904 (diff) |
Merge pull request #226218 from doronbehar/pkg/mlterm-wayland
mlterm: Add support for many build configuration variables
-rw-r--r-- | pkgs/applications/terminal-emulators/mlterm/default.nix | 172 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 5 |
2 files changed, 140 insertions, 37 deletions
diff --git a/pkgs/applications/terminal-emulators/mlterm/default.nix b/pkgs/applications/terminal-emulators/mlterm/default.nix index cc26d4eea295d..217c6552efdd6 100644 --- a/pkgs/applications/terminal-emulators/mlterm/default.nix +++ b/pkgs/applications/terminal-emulators/mlterm/default.nix @@ -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"; @@ -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 ]; @@ -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; @@ -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; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 61f45316eb0ab..5ca1ade501839 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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 { }; |