9 let wrapper = { pythonPackages ? (_: [ ]), plugins ? (_: [ ]), baseConfig ? null }:
11 plugins' = plugins unwrapped.plugins;
12 extraPythonPackages = builtins.concatLists (map (p: p.propagatedBuildInputs or [ ]) plugins');
15 name = "${unwrapped.pname}-with-plugins-${unwrapped.version}";
18 paths = lib.optional (baseConfig != null) unwrapped ++ plugins';
19 pythonPath = lib.optional (baseConfig == null) unwrapped ++ pythonPackages python3.pkgs ++ extraPythonPackages;
21 nativeBuildInputs = [ python3.pkgs.wrapPython ];
24 rm -f $out/nix-support/propagated-build-inputs
25 rmdir $out/nix-support || true
26 ${lib.optionalString (baseConfig != null) ''
27 rm $out/${python3.sitePackages}/maubot/example-config.yaml
28 substituteAll ${(formats.yaml { }).generate "example-config.yaml" (lib.recursiveUpdate baseConfig {
29 plugin_directories = lib.optionalAttrs (plugins' != []) {
30 load = [ "@out@/lib/maubot-plugins" ] ++ (baseConfig.plugin_directories.load or []);
32 # Normally it should be set to false by default to take it from package
33 # root, but aiohttp doesn't follow symlinks when serving static files
34 # unless follow_symlinks=True is passed. Instead of patching maubot, use
35 # this non-invasive approach
36 # XXX: would patching maubot be better? See:
37 # https://github.com/maubot/maubot/blob/75879cfb9370aade6fa0e84e1dde47222625139a/maubot/server.py#L106
38 server.override_resource_path =
39 if builtins.isNull (baseConfig.server.override_resource_path or null)
40 then "${unwrapped}/${python3.sitePackages}/maubot/management/frontend/build"
41 else baseConfig.server.override_resource_path;
42 })} $out/${python3.sitePackages}/maubot/example-config.yaml
46 cp $unwrapped/bin/.mbc-wrapped $out/bin/mbc
47 cp $unwrapped/bin/.maubot-wrapped $out/bin/maubot
48 wrapPythonProgramsIn "$out/bin" "${lib.optionalString (baseConfig != null) "$out "}$pythonPath"
54 withPythonPackages = filter: wrapper {
55 pythonPackages = pkgs: pythonPackages pkgs ++ filter pkgs;
56 inherit plugins baseConfig;
58 withPlugins = filter: wrapper {
59 plugins = pkgs: plugins pkgs ++ filter pkgs;
60 inherit pythonPackages baseConfig;
62 withBaseConfig = baseConfig: wrapper {
63 inherit baseConfig pythonPackages plugins;
67 meta.priority = (unwrapped.meta.priority or lib.meta.defaultPriority) - 1;