rxvt-unicode: support self-depending plugins in wrapper

This commit is contained in:
rnhmjoj 2020-01-08 23:39:55 +01:00
parent 27b3df0840
commit dcfff7cf09
No known key found for this signature in database
GPG key ID: BFBAF4C975F76450

View file

@ -4,24 +4,35 @@
, lib , lib
, rxvt-unicode-unwrapped , rxvt-unicode-unwrapped
, perlPackages , perlPackages
, configure ? { availablePlugins, ... }:
{ plugins = builtins.attrValues availablePlugins;
extraDeps = [ ];
perlDeps = [ ];
}
}: }:
let let
availablePlugins = import ../rxvt-unicode-plugins { inherit callPackage; }; availablePlugins = import ../rxvt-unicode-plugins { inherit callPackage; };
wrapper = # Transform the string "self" to the plugin itself.
{ configure ? { availablePlugins, ... }: # It's needed for plugins like bidi who depends on the perl
{ plugins = builtins.attrValues availablePlugins; # package the provide themself.
extraDeps = [ ]; mkPerlDeps = p:
perlDeps = [ ]; let deps = p.perlPackages or [ ];
} in map (x: if x == "self" then p else x) deps;
}:
# The wrapper is called with a `configure` function
# that takes the urxvt plugins as input and produce
# the configuration of the wrapper: list of plugins,
# extra dependencies and perl dependencies.
# This provides simple way to customize urxvt using
# the `.override` mechanism.
wrapper = { configure, ... }:
let let
config = configure { inherit availablePlugins; }; config = configure { inherit availablePlugins; };
plugins = config.plugins or (builtins.attrValues availablePlugins); plugins = config.plugins or (builtins.attrValues availablePlugins);
extraDeps = config.extraDeps or [ ]; extraDeps = config.extraDeps or [ ];
perlDeps = (config.perlDeps or [ ]) ++ lib.concatMap (p: p.perlPackages or [ ]) plugins; perlDeps = (config.perlDeps or [ ]) ++ lib.concatMap mkPerlDeps plugins;
in in
symlinkJoin { symlinkJoin {
name = "rxvt-unicode-${rxvt-unicode-unwrapped.version}"; name = "rxvt-unicode-${rxvt-unicode-unwrapped.version}";
@ -43,4 +54,4 @@ let
}; };
in in
lib.makeOverridable wrapper { } lib.makeOverridable wrapper { inherit configure; }