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-vvwKbzGlvv2LTbXfJxQVM3nUXFGntgJxsku6cbRxCzw=";
24 python = python3.override (old: {
25 packageOverrides = lib.composeManyExtensions
26 ((if old ? packageOverrides then [ old.packageOverrides ] else [ ]) ++ [ newPackageOverrides ]);
29 plugins = ps: with ps; {
30 poetry-audit-plugin = callPackage ./plugins/poetry-audit-plugin.nix { };
31 poetry-plugin-export = callPackage ./plugins/poetry-plugin-export.nix { };
32 poetry-plugin-up = callPackage ./plugins/poetry-plugin-up.nix { };
33 poetry-plugin-poeblix = callPackage ./plugins/poetry-plugin-poeblix.nix { };
36 # selector is a function mapping pythonPackages to a list of plugins
37 # e.g. poetry.withPlugins (ps: with ps; [ poetry-plugin-up ])
38 withPlugins = selector: let
39 selected = selector (plugins python.pkgs);
40 in python.pkgs.toPythonApplication (python.pkgs.poetry.overridePythonAttrs (old: {
41 propagatedBuildInputs = old.propagatedBuildInputs ++ selected;
43 # save some build time when adding plugins by disabling tests
44 doCheck = selected == [ ];
46 # Propagating dependencies leaks them through $PYTHONPATH which causes issues
47 # when used in nix-shell.
49 rm $out/nix-support/propagated-build-inputs
53 plugins = plugins python.pkgs;
54 inherit withPlugins python;
57 in withPlugins (ps: [ ])