Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add poetryEnv option to the python kernel. #475

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions modules/kernels/python/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import ./../../poetry.nix {
self,
system,
# custom arguments
poetryEnv ? null,
pkgs ? self.inputs.nixpkgs.legacyPackages.${system},
name ? "python",
displayName ? "Python3",
Expand All @@ -34,20 +35,23 @@ import ./../../poetry.nix {
ignoreCollisions ? false,
}: let
env =
(poetry2nix.mkPoetryEnv {
inherit
projectDir
pyproject
poetrylock
overrides
python
editablePackageSources
extraPackages
preferWheels
groups
;
})
.override (args: {inherit ignoreCollisions;});
if poetryEnv != null
then poetryEnv
else
(poetry2nix.mkPoetryEnv {
inherit
projectDir
pyproject
poetrylock
overrides
python
editablePackageSources
extraPackages
preferWheels
groups
;
})
.override (args: {inherit ignoreCollisions;});

allRuntimePackages = requiredRuntimePackages ++ runtimePackages;

Expand Down
1 change: 1 addition & 0 deletions modules/poetry.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
rec {
inherit
(config)
poetryEnv
projectDir
pyproject
poetrylock
Expand Down
9 changes: 9 additions & 0 deletions modules/types/poetry.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
}: let
inherit (lib) types;
in {
poetryEnv = lib.mkOption {
type = types.nullOr types.attrs;
default = null;
example = lib.literalExpression ''poetry2nix.mkPoetryEnv { projectDir = ./.; }'';
description = lib.mdDoc ''
An existing poetry environment to use instead of creating a new one.
'';
};

projectDir = lib.mkOption {
type = types.path;
default = self + "/modules/kernels/${kernelName}";
Expand Down