1 { lib, python3, fetchFromGitHub }:
6 poetry = self.callPackage ./unwrapped.nix { };
8 # The versions of Poetry and poetry-core need to match exactly,
9 # and poetry-core in nixpkgs requires a staging cycle to be updated,
10 # so apply an override here.
12 # We keep the override around even when the versions match, as
13 # it's likely to become relevant again after the next Poetry update.
14 poetry-core = super.poetry-core.overridePythonAttrs (old: rec {
16 src = fetchFromGitHub {
17 owner = "python-poetry";
19 rev = "refs/tags/${version}";
20 hash = "sha256-L8lR9sUdRYqjkDCQ0XHXZm5X6xD40t1gxlGiovvb/+8=";
25 python = python3.override (old: {
27 packageOverrides = lib.composeManyExtensions
28 ((if old ? packageOverrides then [ old.packageOverrides ] else [ ]) ++ [ newPackageOverrides ]);
31 plugins = ps: with ps; {
32 poetry-audit-plugin = callPackage ./plugins/poetry-audit-plugin.nix { };
33 poetry-plugin-export = callPackage ./plugins/poetry-plugin-export.nix { };
34 poetry-plugin-up = callPackage ./plugins/poetry-plugin-up.nix { };
35 poetry-plugin-poeblix = callPackage ./plugins/poetry-plugin-poeblix.nix { };
38 # selector is a function mapping pythonPackages to a list of plugins
39 # e.g. poetry.withPlugins (ps: with ps; [ poetry-plugin-up ])
40 withPlugins = selector: let
41 selected = selector (plugins python.pkgs);
42 in python.pkgs.toPythonApplication (python.pkgs.poetry.overridePythonAttrs (old: {
43 dependencies = old.dependencies ++ selected;
45 # save some build time when adding plugins by disabling tests
46 doCheck = selected == [ ];
48 # Propagating dependencies leaks them through $PYTHONPATH which causes issues
49 # when used in nix-shell.
51 rm $out/nix-support/propagated-build-inputs
55 plugins = plugins python.pkgs;
56 inherit withPlugins python;
59 in withPlugins (ps: [ ])