Help with poetry2nix nixpkgs overlay

I was trying to build an external python package using poetry2nix, and I’m struggling to even use the poetry2nix overlay.

I got the error: poetry2nix is now maintained out-of-tree. Please use https://github.com/nix-community/poetry2nix/

even though I already added poetry2nix to my flake.

this is my config (the relevant part)

# flake.nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    poetry2nix.url = "github:nix-community/poetry2nix";
  };

  outputs = { self, nixpkgs, poetry2nix, ... }@inputs:
    let
      system = "x86_64-linux";
      hostname = "peal"

      pkgs = import nixpkgs{
        inherit system;
        overlays = [poetry2nix.overlays.default];
      };
      # create a custom "mkPoetryApplication" API function that under the hood uses
      # the packages and versions (python3, poetry etc.) from our pinned nixpkgs above:
      myPythonApp = pkgs.poetry2nix.mkPoetryApplication { projectDir = self; };
    in
  {
    nixosConfigurations."${hostname}" = nixpkgs.lib.nixosSystem {
      inherit system;
      specialArgs = { inherit inputs; };

      modules = [./nixos.nix];
  };
}
# nixos.nix
{pkgs, ...}:{

  environment.systemPackages = with pkgs; [
    (callpackage ./thePythonPackage.nix{})
  };

}
# ./thePythonPackage.nix

{
stdenv
, fetchFromGitHub
, poetry2nix
}:

let

  src = fetchFromGitHub {
    owner = "foo";
    repo = "bar";
    rev = "foo";
    hash = "foobar";
  };
in
  poetry2nix.mkPoetryApplication {
    projectDir = src;
  }

Can someone point out what i was doing wrong? I suspect that I did something wrong with the overlay but I can’t quite wrap my head around it

Because the overlay is not applied to the nixpkgs instance used by your NixOS config.

You need something like

{ inputs, ... }:
{
  nixpkgs.overlays = [ inputs.poetry2nix.overlays.default ];
}

For example, if you want to work this into some existing file like your nixos.nix:

{ inputs, pkgs, ... }:
{
  environment.systemPackages = [
    (pkgs.callPackage ./thePythonPackage.nix {})
  };

  nixpkgs.overlays = [ inputs.poetry2nix.overlays.default ];
}

But in my flake.nix I have already defined the overlay.

Does this not matter until you actually define it into your nixos.nix?

     pkgs = import nixpkgs{
        inherit system;
        overlays = [poetry2nix.overlays.default];
      };

That’s just dead code.