I can't create a python shell with flakes: attribute 'mkPoetryEnv' missing

Maybe i should use poetry2nix from pkgs? Or i should use mkPoetryApp, but i need only a shell.

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
    poetry2nix = {
      url = "github:nix-community/poetry2nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, poetry2nix }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
      env = poetry2nix.mkPoetryEnv {
        projectDir = ./.;
        python = pkgs.python311;
        overrides = poetry2nix.overrides.withDefaults;
      };
    in
    {
      devShell."${system}" = pkgs.mkShell {
        buildInputs = with pkgs; [
          env
          poetry
        ];
      };
    };
}

Error:

error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'nix-shell'
         whose name attribute is located at /nix/store/jxqmbf290yk88cil7h6yp9hvkxx38ddb-source/pkgs/stdenv/generic/make-derivation.nix:303:7

       … while evaluating attribute 'buildInputs' of derivation 'nix-shell'

         at /nix/store/jxqmbf290yk88cil7h6yp9hvkxx38ddb-source/pkgs/stdenv/generic/make-derivation.nix:350:7:

          349|       depsHostHost                = lib.elemAt (lib.elemAt dependencies 1) 0;
          350|       buildInputs                 = lib.elemAt (lib.elemAt dependencies 1) 1;
             |       ^
          351|       depsTargetTarget            = lib.elemAt (lib.elemAt dependencies 2) 0;

       error: attribute 'mkPoetryEnv' missing

       at /nix/store/k3l75azz80jxp533c76hg93ixv064sda-source/flake.nix:14:13:

           13|       pkgs = nixpkgs.legacyPackages.${system};
           14|       env = poetry2nix.mkPoetryEnv {
             |             ^
           15|         projectDir = ./.;
error: getting status of '/home/user/project/.direnv/flake-profile.394456': No such file or directory

That’s not a valid flake output attribute. You’ll need something like:

poetry2nix.legacyPackages.${system}.mkPoetryEnv
1 Like