poetry2nix/pkgs/poetry/default.nix

58 lines
1.8 KiB
Nix
Raw Permalink Normal View History

{ lib
, poetry2nix
, python
, fetchFromGitHub
, projectDir ? ./.
, pyproject ? projectDir + "/pyproject.toml"
, poetrylock ? projectDir + "/poetry.lock"
}:
2019-11-19 14:50:31 +00:00
2020-01-18 22:12:40 +00:00
poetry2nix.mkPoetryApplication {
2019-11-19 14:50:31 +00:00
inherit python;
inherit projectDir pyproject poetrylock;
2019-11-19 14:50:31 +00:00
# Don't include poetry in inputs
__isBootstrap = true;
2020-01-18 22:12:40 +00:00
src = fetchFromGitHub (lib.importJSON ./src.json);
2019-11-19 14:50:31 +00:00
# "Vendor" dependencies (for build-system support)
postPatch = ''
2020-10-01 14:36:24 +02:00
echo "import sys" >> poetry/__init__.py
for path in $propagatedBuildInputs; do
echo "sys.path.insert(0, \"$path\")" >> poetry/__init__.py
2019-11-19 14:50:31 +00:00
done
'';
postInstall = ''
# Figure out the location of poetry.core
# As poetry.core is using the same root import name as the poetry package and the python module system wont look for the root
# in the separate second location we need to link poetry.core to poetry
ln -s $(python -c 'import poetry.core; import os.path; print(os.path.dirname(poetry.core.__file__))') $out/${python.sitePackages}/poetry/core
2019-11-19 14:50:31 +00:00
mkdir -p "$out/share/bash-completion/completions"
"$out/bin/poetry" completions bash > "$out/share/bash-completion/completions/poetry"
mkdir -p "$out/share/zsh/vendor-completions"
"$out/bin/poetry" completions zsh > "$out/share/zsh/vendor-completions/_poetry"
mkdir -p "$out/share/fish/vendor_completions.d"
"$out/bin/poetry" completions fish > "$out/share/fish/vendor_completions.d/poetry.fish"
'';
# Propagating dependencies leads to issues downstream
# We've already patched poetry to prefer "vendored" dependencies
postFixup = ''
rm $out/nix-support/propagated-build-inputs
'';
# Fails because of impurities (network, git etc etc)
doCheck = false;
meta = with lib; {
inherit (python.meta) platforms;
2020-01-18 22:12:40 +00:00
maintainers = with maintainers; [ adisbladis jakewaksbaum ];
2019-11-19 14:50:31 +00:00
};
}