nixpkgs/pkgs/servers/matrix-synapse/wrapper.nix
Daniel Olsen a695ad5fb5 matrix-synapse: build a pythonEnv out of extraPackages to include dependencies
By just appending site-packages to the extraPackages, you would get situations like
pysaml2 being included in pythonpath, but not its dependencies like pytz and dateutils
2023-12-13 19:48:06 +01:00

45 lines
1.0 KiB
Nix

{ lib
, stdenv
, makeWrapper
, matrix-synapse-unwrapped
, extras ? [
"postgres"
"url-preview"
"user-search"
] ++ lib.optional (lib.meta.availableOn stdenv.hostPlatform matrix-synapse-unwrapped.python.pkgs.systemd) "systemd"
, plugins ? [ ]
, ...
}:
let
extraPackages = lib.concatMap (extra: matrix-synapse-unwrapped.optional-dependencies.${extra}) (lib.unique extras);
pythonEnv = matrix-synapse-unwrapped.python.buildEnv.override {
extraLibs = extraPackages ++ plugins;
};
searchPath = "${pythonEnv}/${matrix-synapse-unwrapped.python.sitePackages}";
in
stdenv.mkDerivation {
name = (lib.appendToName "wrapped" matrix-synapse-unwrapped).name;
nativeBuildInputs = [
makeWrapper
];
buildCommand = ''
for bin in ${matrix-synapse-unwrapped}/bin/*; do
echo $bin
makeWrapper "$bin" "$out/bin/$(basename $bin)" \
--set PYTHONPATH ${searchPath}
done;
'';
passthru = {
unwrapped = matrix-synapse-unwrapped;
# for backward compatibility
inherit (matrix-synapse-unwrapped) plugins tools;
};
}