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

Conflict between extraPackages and overrides #1692

Open
jonathan-conder opened this issue Jun 10, 2024 · 0 comments
Open

Conflict between extraPackages and overrides #1692

jonathan-conder opened this issue Jun 10, 2024 · 0 comments

Comments

@jonathan-conder
Copy link
Contributor

Describe the issue

I'm attempting to add python-lsp-ruff to extraPackages, but I get this error:

       error: attribute 'ruff' missing

       at /nix/store/lpqygnph8c5l7ajkmqr4rff0pvkfz1f6-source/overrides/default.nix:3229:9:

         3228|         in
         3229|         prev.ruff.overridePythonAttrs (old:
             |         ^
         3230|           let
       Did you mean one of cruft, daff, ruffus, runs or tuf?

The issue seems to be that ruff isn't in python3Packages, but the overlay assumes it is. Usually an earlier overlay will add it, from poetry.lock.

I found a workaround which I've left commented out below. If it suits I can make a PR to remove ruff from the overlay if prev.ruff doesn't exist. Or maybe the overlay shouldn't be applied to extraPackages? An alternative would be add ruff to python3Packages in nixpkgs.

Additional context

flake.nix:

{
  description = "MWE";

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

  outputs = {
    self,
    nixpkgs,
    poetry2nix,
  }: let
    toPackages = _: pkgs: let
      poetryLib = poetry2nix.lib.mkPoetry2Nix {inherit pkgs;};

      # overlay = final: prev: {inherit (pkgs) ruff;};
    in {
      default = poetryLib.mkPoetryEnv {
        projectDir = self;

        extraPackages = ps: [ps.python-lsp-ruff];

        # overrides = poetryLib.defaultPoetryOverrides.overrideOverlay overlay;
      };
    };
  in {
    packages = builtins.mapAttrs toPackages nixpkgs.legacyPackages;
  };
}

pyproject.toml:

[tool.poetry]
name = "mwe"
version = "0.1.0"
description = ""
authors = ["Your Name <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

poetry.lock:

# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand.
package = []

[metadata]
lock-version = "2.0"
python-versions = "^3.11"
content-hash = "81b2fa642d7f2d1219cf80112ace12d689d053d81be7f7addb98144d56fc0fb2"
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

1 participant