2023-11-16 04:20:00 +00:00
|
|
|
{ python3, fetchFromGitHub }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
let
|
2023-02-02 18:25:31 +00:00
|
|
|
python = python3.override {
|
2023-11-16 04:20:00 +00:00
|
|
|
packageOverrides = self: super: rec {
|
2023-02-09 11:40:11 +00:00
|
|
|
poetry = self.callPackage ./unwrapped.nix { };
|
|
|
|
|
2023-11-16 04:20:00 +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.
|
2023-03-24 00:07:29 +00:00
|
|
|
poetry-core = super.poetry-core.overridePythonAttrs (old: rec {
|
2023-11-16 04:20:00 +00:00
|
|
|
version = poetry.version;
|
2023-03-24 00:07:29 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "python-poetry";
|
|
|
|
repo = "poetry-core";
|
|
|
|
rev = version;
|
2023-10-09 19:29:22 +00:00
|
|
|
hash = "sha256-OfY2zc+5CgOrgbiPVnvMdT4h1S7Aek8S7iThl6azmsk=";
|
2023-03-24 00:07:29 +00:00
|
|
|
};
|
|
|
|
});
|
2023-07-15 17:15:38 +00:00
|
|
|
} // (plugins self);
|
2023-02-02 18:25:31 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
plugins = ps: with ps; {
|
2023-02-09 11:40:11 +00:00
|
|
|
poetry-audit-plugin = callPackage ./plugins/poetry-audit-plugin.nix { };
|
2023-07-15 17:15:38 +00:00
|
|
|
poetry-plugin-export = callPackage ./plugins/poetry-plugin-export.nix { };
|
2023-02-09 11:40:11 +00:00
|
|
|
poetry-plugin-up = callPackage ./plugins/poetry-plugin-up.nix { };
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-02-09 11:40:11 +00:00
|
|
|
# selector is a function mapping pythonPackages to a list of plugins
|
|
|
|
# e.g. poetry.withPlugins (ps: with ps; [ poetry-plugin-up ])
|
|
|
|
withPlugins = selector: let
|
2023-07-15 17:15:38 +00:00
|
|
|
selected = selector (plugins python.pkgs);
|
2023-02-09 11:40:11 +00:00
|
|
|
in python.pkgs.toPythonApplication (python.pkgs.poetry.overridePythonAttrs (old: {
|
|
|
|
propagatedBuildInputs = old.propagatedBuildInputs ++ selected;
|
2023-01-20 10:41:00 +00:00
|
|
|
|
2023-02-09 11:40:11 +00:00
|
|
|
# save some build time when adding plugins by disabling tests
|
|
|
|
doCheck = selected == [ ];
|
2022-01-13 20:06:32 +00:00
|
|
|
|
2023-02-09 11:40:11 +00:00
|
|
|
# Propagating dependencies leaks them through $PYTHONPATH which causes issues
|
|
|
|
# when used in nix-shell.
|
|
|
|
postFixup = ''
|
|
|
|
rm $out/nix-support/propagated-build-inputs
|
|
|
|
'';
|
2022-10-30 15:09:59 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
passthru = {
|
|
|
|
plugins = plugins python.pkgs;
|
|
|
|
inherit withPlugins python;
|
2023-02-09 11:40:11 +00:00
|
|
|
};
|
|
|
|
}));
|
|
|
|
in withPlugins (ps: [ ])
|