Use python.withPackages for extensions to avoid conflicts

Instead of trying to strip fava from extension dependencies, create
a unified Python environment with python.withPackages that includes
both fava and all extensions. Python handles deduplication naturally.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Patrick Mulligan 2026-04-01 23:57:01 -04:00
parent 97f8f97ca2
commit a5dc59600e

View file

@ -5,19 +5,14 @@ with lib;
let
cfg = config.services.fava;
# Build fava with extensions included in its Python environment.
# Extensions that depend on fava are overridden to remove it from their
# dependencies, avoiding duplicate package conflicts in the closure.
stripFavaDep = ext: ext.overridePythonAttrs (old: {
dependencies = builtins.filter (dep: (dep.pname or "") != "fava") (old.dependencies or []);
dontCheckRuntimeDeps = true;
});
# Build a Python environment with fava and all extensions.
# This avoids duplicate package conflicts by letting Python resolve
# shared dependencies (like fava itself) in a single environment.
python = cfg.package.pythonModule;
favaWithExtensions = if cfg.extensions == [] then cfg.package else
cfg.package.overridePythonAttrs (old: {
dependencies = (old.dependencies or []) ++ map stripFavaDep cfg.extensions;
dontCheckForDuplicates = true;
});
let
env = python.withPackages (ps: [ cfg.package ] ++ cfg.extensions);
in env;
in {
options.services.fava = {