Adding a custom package to a Python application's environment (Fava plugin)

I track my personal finances using beancount. I have a plugin that I wrote for myself, which in beancount is a python module that is installed in the same python environment, so that beancount can import your module.

I am running a small home server using NixOS. (Loving the stability so far… even if I sometimes struggle with nix lang :slight_smile: ). I am trying to run fava (a beancount Web UI) on my server so that my partner can view and edit our shared accounting data.

I was able to setup fava on my server as a systemd service and that mostly^1 works, but i can’t seem to figure out out to get my custom plugin installed in the same environment as fava. My latest attempt was to replace the python3 environment via an overlay, but I suspect I am misunderstanding the python3 parameter.

final: prev: 
  plugins = prev.pkgs.python310Packages.buildPythonPackage {
      name= "beanplugins";
      src = ./beanplugins;
      propagatedBuildInputs = [
      pythonEnv = prev.pkgs.python3.withPackages(ps: [ 
    fava = prev.fava.override { python3 = pythonEnv; };

P.S. I started out asking about overlays and Python, but then I figured, let me ask about what I actually wanted to do. I would really like to understand what is happening though. I am having a lot of trouble understanding overlays.

[1] Right now the systemd service timesout while starting, crashes, and then successfully start when systemd retries. It “works”, but my nixos rebuild takes about 60 seconds while it times out.