Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package overrides using a mini module system #312432

Draft
wants to merge 28 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
02e810b
ffmpeg: small first attempt
Atemu May 17, 2024
0d3005f
mlterm: initial mini-module conversion
Atemu May 17, 2024
77762e4
mlterm: further conversion
Atemu May 17, 2024
33ac366
mlterm: finish conversion using helper function
Atemu May 17, 2024
8943dec
mlterm: fix all-packages override
Atemu May 17, 2024
5676088
wip new options system with type
Atemu Aug 17, 2024
3afb8b1
port buildInputs
Atemu Aug 23, 2024
698eafe
port configureFlags
Atemu Aug 26, 2024
39606cc
cleanup
Atemu Aug 26, 2024
fc770c5
move variant description to option description
Atemu Aug 26, 2024
20a4a42
convert non-feature options
Atemu Sep 6, 2024
767516f
add back descriptions as first-class data entry
Atemu Sep 6, 2024
42ae1cd
small improvements
Atemu Sep 6, 2024
40490d1
slight description simplification
Atemu Sep 6, 2024
cff4b07
cleanup module eval application
Atemu Sep 12, 2024
4383197
move options declaration to generic.nix
Atemu Sep 12, 2024
726b8b5
get rid of with aliases
Atemu Sep 14, 2024
40259ce
get rid of remaining with* variables
Atemu Sep 14, 2024
218ef87
small refactors
Atemu Sep 14, 2024
9ec6044
refactor check env var
Atemu Sep 14, 2024
297dd92
fix formatting
Atemu Sep 14, 2024
ccb7b7f
remove debug passthru
Atemu Sep 14, 2024
2ba0097
actually delete options.nix
Atemu Sep 14, 2024
a0a07ac
merge ffmpegFlags with default values
Atemu Sep 15, 2024
c2afc38
make description internal
Atemu Sep 16, 2024
ba6e0f9
improve descriptions
Atemu Sep 16, 2024
1dd2070
missing alsa gate
Atemu Sep 16, 2024
4560290
qt-faststart only in full
Atemu Sep 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 20 additions & 61 deletions pkgs/applications/terminal-emulators/mlterm/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,71 +20,13 @@
, 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;
# From some reason, upstream's ./configure script disables compilation of the
# external tool `mlconfig` if `enableGuis.fb == true`. This behavior is not
# documentd in `./configure --help`, and it is reported here:
# https://github.com/arakiken/mlterm/issues/73
fb = false;
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."
)
, configuration ? { }
}:

let
Expand All @@ -96,6 +38,23 @@ let
in
lib.withFeatureAs (commaSepList != "") featureName commaSepList
;
eval = lib.evalModules {
modules = [
./options.nix
configuration
{
_module.args = {
inherit stdenv;
};
}
];
};
inherit (eval) config;
# For compat in order to not need to touch the entire drv
enableGuis = config.gui;
enableTypeEngines = config.typeEngines;
enableTools = config.tools;
enableFeatures = config.features;
in stdenv.mkDerivation (finalAttrs: {
pname = "mlterm";
version = "3.9.3";
Expand Down Expand Up @@ -173,7 +132,7 @@ in stdenv.mkDerivation (finalAttrs: {
(withFeaturesList "type-engines" enableTypeEngines)
(withFeaturesList "tools" enableTools)
(withFeaturesList "gui" enableGuis)
(lib.withFeature enableX11 "x")
(lib.withFeature config.x11 "x")
] ++ lib.optionals (gtk != null) [
"--with-gtk=${lib.versions.major gtk.version}.0"
] ++ (lib.mapAttrsToList (n: v: lib.enableFeature v n) enableFeatures) ++ [
Expand All @@ -193,7 +152,7 @@ in stdenv.mkDerivation (finalAttrs: {

desktopItem = makeDesktopItem {
name = "mlterm";
exec = "${desktopBinary} %U";
exec = "${config.desktopBinary} %U";
icon = "mlterm";
type = "Application";
comment = "Multi Lingual TERMinal emulator";
Expand Down
81 changes: 81 additions & 0 deletions pkgs/applications/terminal-emulators/mlterm/options.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
lib,
config,
stdenv,
...
}:

let
# For prototyping. In reality you may want to declare options manually
quickConvert = lib.mapAttrs (n: v: lib.mkOption { default = v; });
in

{
options = {
gui = {
xlib = lib.mkOption { default = config.x11; };
# From some reason, upstream's ./configure script disables compilation of the
# external tool `mlconfig` if `config.gui.fb == true`. This behavior is not
# documentd in `./configure --help`, and it is reported here:
# https://github.com/arakiken/mlterm/issues/73
fb = lib.mkOption { default = false; };
quartz = lib.mkOption { default = stdenv.isDarwin; };
wayland = lib.mkOption { default = stdenv.isLinux; };
sdl2 = lib.mkOption { default = true; };
};

# Whether to enable the X window system
x11 = lib.mkOption { default = stdenv.isLinux; };

typeEngines = {
# List of typing engines, the default list enables compiling all of the
# available ones, as recorded on release 3.9.3
xcore = lib.mkOption { default = false; }; # Considered legacy
xft = lib.mkOption { default = config.x11; };
cairo = lib.mkOption { default = true; };
};

# 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.
features = quickConvert {
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;
};

# List of external tools to create, this default list includes all default
# tools, as recorded on release 3.9.3.
tools = quickConvert {
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;
};

desktopBinary = lib.mkOption {
default =
# Configure the Exec directive in the generated .desktop file
if config.gui.xlib then
"mlterm"
else if config.gui.wayland then
"mlterm-wl"
else if config.gui.sdl2 then
"mlterm-sdl2"
else
throw "mlterm: couldn't figure out what desktopBinary to use.";
};
};
}
Loading