packageOverrides get ignored?

I recently used pkgs.python3.override in order to create a minimal python environment for a container with some additional packages. I also need to use poetry2nix for the packages that are not available in nix. However I now discovered that non of the overrides are actually packaged up. It took me a while to discover this since some of the packages were also pulled in as part of the poetry dependencies.

Excerpt from my flake.nix:

mypython = pkgs.python3.override {
      packageOverrides = self: super: {
        matplotlib = pkgs.python3Packages.matplotlib; # use the nixpkgs version
        #notebook = pkgs.python3Packages.notebook; # use the nixpkgs version
        nbformat = pkgs.python3Packages.nbformat; # use the nixpkgs version
        numpy = pkgs.python3Packages.numpy; # use the nixpkgs version
        plotly = pkgs.python3Packages.plotly; # use the nixpkgs version
        scipy = pkgs.python3Packages.scipy; # use the nixpkgs version
      };
    };
    p2n = import poetry2nix { };  # use when workaround is no longer necessary
    pythonWithPackages = p2n.mkPoetryEnv {
      python = mypython;
      pyproject = ./pyproject.toml;
      poetrylock = ./poetry.lock; # make sure it is added to git!
    };
    pythonLayer = pkgs.dockerTools.buildLayeredImage {
      name = "python-layer";
      contents = [
        pythonWithPackages
        pkgs.coreutils
        pkgs.bash
        pkgs.fish
        pkgs.nano];
    };

none of the packages get actually packaged. What am I missing?
Any pointers are highly appreciated.

Maybe you missed the withPackages step :thinking:

I’m not sure since as I understand it, the setup I use defines my own pythonWithPackages which is made up of the packages as provided by p2n.mkPoetryEnv which in turn uses my definition of python which in turn is defined by the overrides. Though I’m really curious about the self: super: part since non of that seems to be used “internally” in the definition list. But unfortunately my knowledge of the nix language is at an end there.