1{
2 symlinkJoin,
3 makeWrapper,
4 lib,
5 rxvt-unicode-unwrapped,
6 rxvt-unicode-plugins,
7 perlPackages,
8 nixosTests,
9 configure ?
10 { availablePlugins, ... }:
11 {
12 plugins = builtins.attrValues availablePlugins;
13 extraDeps = [ ];
14 perlDeps = [ ];
15 },
16}:
17
18let
19 availablePlugins = rxvt-unicode-plugins;
20
21 # Transform the string "self" to the plugin itself.
22 # It's needed for plugins like bidi who depends on the perl
23 # package they provide themself.
24 mkPerlDeps =
25 p:
26 let
27 deps = p.perlPackages or [ ];
28 in
29 map (x: if x == "self" then p else x) deps;
30
31 # The wrapper is called with a `configure` function
32 # that takes the urxvt plugins as input and produce
33 # the configuration of the wrapper: list of plugins,
34 # extra dependencies and perl dependencies.
35 # This provides simple way to customize urxvt using
36 # the `.override` mechanism.
37 wrapper =
38 { configure, ... }:
39 let
40 config = configure { inherit availablePlugins; };
41 plugins = config.plugins or (builtins.attrValues availablePlugins);
42 extraDeps = config.extraDeps or [ ];
43 perlDeps = (config.perlDeps or [ ]) ++ lib.concatMap mkPerlDeps plugins;
44 in
45 symlinkJoin {
46 name = "rxvt-unicode-${rxvt-unicode-unwrapped.version}";
47
48 paths = [ rxvt-unicode-unwrapped ] ++ plugins ++ extraDeps;
49
50 nativeBuildInputs = [ makeWrapper ];
51
52 postBuild = ''
53 wrapProgram $out/bin/urxvt \
54 --prefix PERL5LIB : "${perlPackages.makePerlPath perlDeps}" \
55 --suffix-each URXVT_PERL_LIB ':' "$out/lib/urxvt/perl"
56 wrapProgram $out/bin/urxvtd \
57 --prefix PERL5LIB : "${perlPackages.makePerlPath perlDeps}" \
58 --suffix-each URXVT_PERL_LIB ':' "$out/lib/urxvt/perl"
59 '';
60
61 inherit (rxvt-unicode-unwrapped) meta;
62
63 passthru = {
64 plugins = plugins;
65 tests.test = nixosTests.terminal-emulators.urxvt;
66 };
67 };
68
69in
70lib.makeOverridable wrapper { inherit configure; }