2020-01-08 21:58:44 +00:00
|
|
|
{ callPackage
|
|
|
|
, symlinkJoin
|
|
|
|
, makeWrapper
|
|
|
|
, lib
|
|
|
|
, rxvt-unicode-unwrapped
|
2020-01-08 22:44:37 +00:00
|
|
|
, rxvt-unicode-plugins
|
2020-01-08 21:58:44 +00:00
|
|
|
, perlPackages
|
2020-01-08 22:39:55 +00:00
|
|
|
, configure ? { availablePlugins, ... }:
|
|
|
|
{ plugins = builtins.attrValues availablePlugins;
|
|
|
|
extraDeps = [ ];
|
|
|
|
perlDeps = [ ];
|
|
|
|
}
|
2020-01-08 21:58:44 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2020-01-08 22:44:37 +00:00
|
|
|
availablePlugins = rxvt-unicode-plugins;
|
2020-01-08 21:58:44 +00:00
|
|
|
|
2020-01-08 22:39:55 +00:00
|
|
|
# Transform the string "self" to the plugin itself.
|
|
|
|
# It's needed for plugins like bidi who depends on the perl
|
2020-01-08 22:44:37 +00:00
|
|
|
# package they provide themself.
|
2020-01-08 22:39:55 +00:00
|
|
|
mkPerlDeps = p:
|
|
|
|
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, ... }:
|
2020-10-28 15:34:17 +00:00
|
|
|
let
|
2020-01-08 21:58:44 +00:00
|
|
|
config = configure { inherit availablePlugins; };
|
|
|
|
plugins = config.plugins or (builtins.attrValues availablePlugins);
|
|
|
|
extraDeps = config.extraDeps or [ ];
|
2020-01-08 22:39:55 +00:00
|
|
|
perlDeps = (config.perlDeps or [ ]) ++ lib.concatMap mkPerlDeps plugins;
|
2020-01-08 21:58:44 +00:00
|
|
|
in
|
|
|
|
symlinkJoin {
|
|
|
|
name = "rxvt-unicode-${rxvt-unicode-unwrapped.version}";
|
|
|
|
|
|
|
|
paths = [ rxvt-unicode-unwrapped ] ++ plugins ++ extraDeps;
|
|
|
|
|
|
|
|
buildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
postBuild = ''
|
|
|
|
wrapProgram $out/bin/urxvt \
|
|
|
|
--prefix PERL5LIB : "${perlPackages.makePerlPath perlDeps}" \
|
|
|
|
--suffix-each URXVT_PERL_LIB ':' "$out/lib/urxvt/perl"
|
|
|
|
wrapProgram $out/bin/urxvtd \
|
|
|
|
--prefix PERL5LIB : "${perlPackages.makePerlPath perlDeps}" \
|
|
|
|
--suffix-each URXVT_PERL_LIB ':' "$out/lib/urxvt/perl"
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru.plugins = plugins;
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
2020-01-08 22:39:55 +00:00
|
|
|
lib.makeOverridable wrapper { inherit configure; }
|