1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
{ lib
, fetchgit
, fetchFromGitHub
, fetchFromGitLab
, fetchFromGitea
, stdenvNoCC
, callPackage
, ensureNewerSourcesForZipFilesHook
, maubot
, python3
, poetry
, formats
}:
let
# pname: plugin id (example: xyz.maubot.echo)
# version: plugin version
# other attributes are passed directly to stdenv.mkDerivation (you at least need src)
buildMaubotPlugin = attrs@{ version, pname, base_config ? null, ... }:
stdenvNoCC.mkDerivation (builtins.removeAttrs attrs [ "base_config" ] // {
pluginName = "${pname}-v${version}.mbp";
nativeBuildInputs = (attrs.nativeBuildInputs or [ ]) ++ [
ensureNewerSourcesForZipFilesHook
maubot
];
buildPhase = ''
runHook preBuild
mbc build
runHook postBuild
'';
postPatch = lib.optionalString (base_config != null) ''
[ -e base-config.yaml ] || (echo "base-config.yaml doesn't exist, can't override it" && exit 1)
cp "${if builtins.isPath base_config || lib.isDerivation base_config then base_config
else if builtins.isString base_config then builtins.toFile "base-config.yaml" base_config
else (formats.yaml { }).generate "base-config.yaml" base_config}" base-config.yaml
'' + attrs.postPatch or "";
installPhase = ''
runHook preInstall
mkdir -p $out/lib/maubot-plugins
install -m 444 $pluginName $out/lib/maubot-plugins
runHook postInstall
'';
});
generated = import ./generated.nix {
inherit lib fetchgit fetchFromGitHub fetchFromGitLab
fetchFromGitea python3 poetry buildMaubotPlugin;
};
in
generated // {
inherit buildMaubotPlugin;
allOfficialPlugins =
builtins.filter
(x: x.isOfficial && !x.meta.broken)
(builtins.attrValues generated);
allPlugins =
builtins.filter
(x: !x.meta.broken)
(builtins.attrValues generated);
}
|