git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #44102 from alyssais/weechat-unwrapped

weechat: seperate weechat-unwrapped from wrapper

commit3e1401f06bff0b45760d5ce1d360dd01bd143d77 authorLinus Heckemann <git@sphalerite.org> dateWed 5 Dec 2018, 13:36 (8 years ago) parentb2c86f49504292
3 files changed+64−74
pkgs/applications/networking/irc/weechat/default.nix+2−73 pkgs/applications/networking/irc/weechat/wrapper.nix+57 pkgs/top-level/all-packages.nix+5−1
pkgs/applications/networking/irc/weechat/default.nix+2−73
@@ -2,7 +2,6 @@
22, ncurses, openssl, aspell, gnutls
33, zlib, curl, pkgconfig, libgcrypt
44, cmake, makeWrapper, libobjc, libresolv, libiconv
5−, writeScriptBin # for withPlugins
65, asciidoctor # manpages
76, guileSupport ? true, guile
87, luaSupport ? true, lua5
@@ -11,8 +10,6 @@
1110, rubySupport ? true, ruby
1211, tclSupport ? true, tcl
1312, extraBuildInputs ? []
14−, configure ? { availablePlugins, ... }: { plugins = builtins.attrValues availablePlugins; }
15−, runCommand, buildEnv
1613}:
1714
1815let
@@ -27,7 +24,7 @@ let
2724 ];
2825 enabledPlugins = builtins.filter (p: p.enabled) plugins;
2926
30− weechat =
27+ in
3128 assert lib.all (p: p.enabled -> ! (builtins.elem null p.buildInputs)) plugins;
3229 stdenv.mkDerivation rec {
3330 version = "2.3";
@@ -82,72 +79,4 @@ let
8279 maintainers = with stdenv.lib.maintainers; [ lovek323 garbas the-kenny lheckemann ma27 ];
8380 platforms = stdenv.lib.platforms.unix;
8481 };
85− };
86−in if configure == null then weechat else
87− let
88− perlInterpreter = perl;
89− availablePlugins = let
90− simplePlugin = name: {pluginFile = "${weechat.${name}}/lib/weechat/plugins/${name}.so";};
91− in rec {
92− python = {
93− pluginFile = "${weechat.python}/lib/weechat/plugins/python.so";
94− withPackages = pkgsFun: (python // {
95− extraEnv = ''
96− export PYTHONHOME="${pythonPackages.python.withPackages pkgsFun}"
97− '';
98− });
99− };
100− perl = (simplePlugin "perl") // {
101− extraEnv = ''
102− export PATH="${perlInterpreter}/bin:$PATH"
103− '';
104− withPackages = pkgsFun: (perl // {
105− extraEnv = ''
106− ${perl.extraEnv}
107− export PERL5LIB=${lib.makeFullPerlPath (pkgsFun perlPackages)}
108− '';
109− });
110− };
111− tcl = simplePlugin "tcl";
112− ruby = simplePlugin "ruby";
113− guile = simplePlugin "guile";
114− lua = simplePlugin "lua";
115− };
116−
117− config = configure { inherit availablePlugins; };
118−
119− plugins = config.plugins or (builtins.attrValues availablePlugins);
120−
121− pluginsDir = runCommand "weechat-plugins" {} ''
122− mkdir -p $out/plugins
123− for plugin in ${lib.concatMapStringsSep " " (p: p.pluginFile) plugins} ; do
124− ln -s $plugin $out/plugins
125− done
126− '';
127−
128− init = let
129− init = builtins.replaceStrings [ "\n" ] [ ";" ] (config.init or "");
130−
131− mkScript = drv: lib.flip map drv.scripts (script: "/script load ${drv}/share/${script}");
132−
133− scripts = builtins.concatStringsSep ";" (lib.foldl (scripts: drv: scripts ++ mkScript drv)
134− [ ] (config.scripts or []));
135− in "${scripts};${init}";
136−
137− mkWeechat = bin: (writeScriptBin bin ''
138− #!${stdenv.shell}
139− export WEECHAT_EXTRA_LIBDIR=${pluginsDir}
140− ${lib.concatMapStringsSep "\n" (p: lib.optionalString (p ? extraEnv) p.extraEnv) plugins}
141− exec ${weechat}/bin/${bin} "$@" --run-command ${lib.escapeShellArg init}
142− '') // {
143− inherit (weechat) name meta;
144− unwrapped = weechat;
145− };
146− in buildEnv {
147− name = "weechat-bin-env-${weechat.version}";
148− paths = [
149− (mkWeechat "weechat")
150− (mkWeechat "weechat-headless")
151− ];
152− meta = weechat.meta;
153− }
82+ }
pkgs/applications/networking/irc/weechat/wrapper.nixnew file+57
@@ -0,0 +1,57 @@
1+{ pythonPackages, perl, runCommand, lib, writeScriptBin, stdenv
2+}:
3+
4+weechat:
5+
6+let
7+ wrapper = {
8+ configure ? { availablePlugins, ... }: { plugins = builtins.attrValues availablePlugins; }
9+ }:
10+
11+ let
12+ perlInterpreter = perl;
13+ config = configure {
14+ availablePlugins = let
15+ simplePlugin = name: { pluginFile = "${weechat.${name}}/lib/weechat/plugins/${name}.so"; };
16+ in rec {
17+ python = {
18+ pluginFile = "${weechat.python}/lib/weechat/plugins/python.so";
19+ withPackages = pkgsFun: (python // {
20+ extraEnv = ''
21+ export PYTHONHOME="${pythonPackages.python.withPackages pkgsFun}"
22+ '';
23+ });
24+ };
25+ perl = (simplePlugin "perl") // {
26+ extraEnv = ''
27+ export PATH="${perlInterpreter}/bin:$PATH"
28+ '';
29+ };
30+ tcl = simplePlugin "tcl";
31+ ruby = simplePlugin "ruby";
32+ guile = simplePlugin "guile";
33+ lua = simplePlugin "lua";
34+ };
35+ };
36+
37+ inherit (config) plugins;
38+
39+ pluginsDir = runCommand "weechat-plugins" {} ''
40+ mkdir -p $out/plugins
41+ for plugin in ${lib.concatMapStringsSep " " (p: p.pluginFile) plugins} ; do
42+ ln -s $plugin $out/plugins
43+ done
44+ '';
45+
46+ in (writeScriptBin "weechat" ''
47+ #!${stdenv.shell}
48+ export WEECHAT_EXTRA_LIBDIR=${pluginsDir}
49+ ${lib.concatMapStringsSep "\n" (p: lib.optionalString (p ? extraEnv) p.extraEnv) plugins}
50+ exec ${weechat}/bin/weechat "$@"
51+ '') // {
52+ name = weechat.name;
53+ unwrapped = weechat;
54+ meta = weechat.meta;
55+ };
56+
57+in lib.makeOverridable wrapper
pkgs/top-level/all-packages.nix+5−1
@@ -19738,12 +19738,16 @@ in
1973819738
1973919739 webtorrent_desktop = callPackage ../applications/video/webtorrent_desktop {};
1974019740
19741− weechat = callPackage ../applications/networking/irc/weechat {
19741+ wrapWeechat = callPackage ../applications/networking/irc/weechat/wrapper.nix { };
19742+
19743+ weechat-unwrapped = callPackage ../applications/networking/irc/weechat {
1974219744 inherit (darwin) libobjc;
1974319745 inherit (darwin) libresolv;
1974419746 guile = guile_2_0;
1974519747 };
1974619748
19749+ weechat = wrapWeechat weechat-unwrapped { };
19750+
1974719751 weechatScripts = callPackage ../applications/networking/irc/weechat/scripts { };
1974819752
1974919753 westonLite = weston.override {