Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: attribute 'defaultPoetryOverrides' missing #1765

Open
luochen1990 opened this issue Aug 6, 2024 · 2 comments
Open

error: attribute 'defaultPoetryOverrides' missing #1765

luochen1990 opened this issue Aug 6, 2024 · 2 comments

Comments

@luochen1990
Copy link

Describe the issue

I'm following this edgecases document to solve the ModuleNotFoundError: No module named 'setuptools' issue.

But got

error: attribute 'defaultPoetryOverrides' missing

Additional context

default.nix/shell.nix/flake.nix:

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

  outputs = { self, nixpkgs, poetry2nix }:
  let
    supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
    eachSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f rec {
      inherit system;
      pkgs = import nixpkgs { inherit system; };
      inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
      python3 = pkgs.python3;
      py-version = pkgs.python3.version;
    });
  in
  rec {

    packages = eachSystem ({mkPoetryApplication, ...}: {
      default = mkPoetryApplication { projectDir = ./.; };
      fix = mkPoetryApplication {
        projectDir = ./.;
        overrides = poetry2nix.defaultPoetryOverrides.extend
          (final: prev: {
            pyright = prev.pyright.overridePythonAttrs
            (
              old: {
                buildInputs = (old.buildInputs or [ ]) ++ [ prev.setuptools ];
              }
            );
          });
      };
    });
  };
}

pyproject.toml:

poetry.lock:

@shipurjan
Copy link

shipurjan commented Aug 31, 2024

I have the same problem

{
  description = "Application packaged using poetry2nix";

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

  outputs =
    {
      self,
      nixpkgs,
      flake-utils,
      poetry2nix,
    }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        # see https://github.com/nix-community/poetry2nix/tree/master#api for more functions and examples.
        pkgs = nixpkgs.legacyPackages.${system};
        inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
      in
      {
        packages = {
          myapp = mkPoetryApplication {
            projectDir = self;
            python = pkgs.python311;
            overrides = poetry2nix.defaultPoetryOverrides.extend (
              self: super: {
                greek-accentuation = super.greek-accentuation.overridePythonAttrs (old: {
                  buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools ];
                });
              }
            );

          };
          default = self.packages.${system}.myapp;
        };

        # Shell for app dependencies.
        #
        #     nix develop
        #
        # Use this shell for developing your app.
        devShells.default = pkgs.mkShell {
          inputsFrom = [ self.packages.${system}.myapp ];
          packages = with pkgs; [
            aria2
          ];
        };
      }
    );
}

Error

➜ nix develop -c $env.SHELL
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/nmks0vzk27aj7ny5110w4fkvr0fqr5db-source/pkgs/stdenv/generic/make-derivation.nix:336:7

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

         at /nix/store/nmks0vzk27aj7ny5110w4fkvr0fqr5db-source/pkgs/stdenv/generic/make-derivation.nix:383:7:

          382|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          383|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          384|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       error: attribute 'defaultPoetryOverrides' missing

       at /nix/store/clq9vdhc4fpvfwsw5p07f6n76zplfxzq-source/flake.nix:32:25:

           31|             python = pkgs.python311;
           32|             overrides = poetry2nix.defaultPoetryOverrides.extend (
             |                         ^
           33|               self: super: {

@shipurjan
Copy link

The solution is in #1457 (comment)

You need to inherit defaultPoetryOverrides just like mkPoetryApplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants