nixpkgs/pkgs/tools/package-management/poetry/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.8 KiB
Nix
Raw Normal View History

2023-10-24 18:16:27 +00:00
{ python3, fetchFromGitHub }:
2019-01-07 18:25:57 +00:00
let
2023-01-23 19:59:16 +00:00
python = python3.override {
2023-10-24 18:16:27 +00:00
packageOverrides = self: super: rec {
2023-02-01 06:27:39 +00:00
poetry = self.callPackage ./unwrapped.nix { };
2023-10-24 18:16:27 +00:00
# The versions of Poetry and poetry-core need to match exactly,
# and poetry-core in nixpkgs requires a staging cycle to be updated,
# so apply an override here.
#
# We keep the override around even when the versions match, as
# it's likely to become relevant again after the next Poetry update.
poetry-core = super.poetry-core.overridePythonAttrs (old: rec {
version = "1.8.1";
2023-10-24 18:16:27 +00:00
src = fetchFromGitHub {
owner = "python-poetry";
repo = "poetry-core";
rev = version;
hash = "sha256-RnCJ67jaL2knwv+Uo7p0zOejHAT73f40weaJnfqOYoM=";
2023-10-24 18:16:27 +00:00
};
});
} // (plugins self);
2023-01-23 19:59:16 +00:00
};
2019-01-07 18:25:57 +00:00
plugins = ps: with ps; {
poetry-audit-plugin = callPackage ./plugins/poetry-audit-plugin.nix { };
poetry-plugin-export = callPackage ./plugins/poetry-plugin-export.nix { };
poetry-plugin-up = callPackage ./plugins/poetry-plugin-up.nix { };
2019-01-07 18:25:57 +00:00
};
2023-02-01 06:27:39 +00:00
# selector is a function mapping pythonPackages to a list of plugins
# e.g. poetry.withPlugins (ps: with ps; [ poetry-plugin-up ])
2023-02-01 06:27:39 +00:00
withPlugins = selector: let
selected = selector (plugins python.pkgs);
2023-02-01 06:27:39 +00:00
in python.pkgs.toPythonApplication (python.pkgs.poetry.overridePythonAttrs (old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ selected;
2023-02-01 06:27:39 +00:00
# save some build time when adding plugins by disabling tests
doCheck = selected == [ ];
2023-02-01 06:27:39 +00:00
# Propagating dependencies leaks them through $PYTHONPATH which causes issues
# when used in nix-shell.
postFixup = ''
rm $out/nix-support/propagated-build-inputs
'';
passthru = {
plugins = plugins python.pkgs;
inherit withPlugins python;
2023-02-01 06:27:39 +00:00
};
}));
in withPlugins (ps: [ ])