2023-10-24 18:16:27 +00:00
|
|
|
{ python3, fetchFromGitHub }:
|
2019-01-07 18:25:57 +00:00
|
|
|
|
2023-01-09 13:43:47 +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 {
|
2023-11-04 23:56:57 +00:00
|
|
|
version = "1.8.1";
|
2023-10-24 18:16:27 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "python-poetry";
|
|
|
|
repo = "poetry-core";
|
|
|
|
rev = version;
|
2023-11-04 23:56:57 +00:00
|
|
|
hash = "sha256-RnCJ67jaL2knwv+Uo7p0zOejHAT73f40weaJnfqOYoM=";
|
2023-10-24 18:16:27 +00:00
|
|
|
};
|
|
|
|
});
|
2023-07-09 02:40:57 +00:00
|
|
|
} // (plugins self);
|
2023-01-23 19:59:16 +00:00
|
|
|
};
|
2019-01-07 18:25:57 +00:00
|
|
|
|
2023-07-09 02:40:57 +00:00
|
|
|
plugins = ps: with ps; {
|
2023-02-02 17:34:49 +00:00
|
|
|
poetry-audit-plugin = callPackage ./plugins/poetry-audit-plugin.nix { };
|
2023-07-09 02:40:57 +00:00
|
|
|
poetry-plugin-export = callPackage ./plugins/poetry-plugin-export.nix { };
|
2023-02-01 06:37:45 +00:00
|
|
|
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
|
2023-02-01 06:37:45 +00:00
|
|
|
# e.g. poetry.withPlugins (ps: with ps; [ poetry-plugin-up ])
|
2023-02-01 06:27:39 +00:00
|
|
|
withPlugins = selector: let
|
2023-07-09 02:40:57 +00:00
|
|
|
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-01-12 03:20:46 +00:00
|
|
|
|
2023-02-01 06:27:39 +00:00
|
|
|
# save some build time when adding plugins by disabling tests
|
|
|
|
doCheck = selected == [ ];
|
2022-01-11 14:19:30 +00:00
|
|
|
|
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
|
|
|
|
'';
|
2022-10-21 16:45:03 +00:00
|
|
|
|
2023-07-09 02:40:57 +00:00
|
|
|
passthru = {
|
|
|
|
plugins = plugins python.pkgs;
|
|
|
|
inherit withPlugins python;
|
2023-02-01 06:27:39 +00:00
|
|
|
};
|
|
|
|
}));
|
|
|
|
in withPlugins (ps: [ ])
|