From b825433bfb167dd1661beaf6de57a8c64f43f3bf Mon Sep 17 00:00:00 2001 From: Matthias Thym Date: Fri, 1 Mar 2024 16:40:42 +0100 Subject: [PATCH 1/9] Add support for specifying Python root directory --- src/modules/languages/python.nix | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/modules/languages/python.nix b/src/modules/languages/python.nix index 05ff0de76..eb624b06c 100644 --- a/src/modules/languages/python.nix +++ b/src/modules/languages/python.nix @@ -43,7 +43,7 @@ let # existing virtual environment. For instance if devenv was started within an venv. unset VIRTUAL_ENV - VENV_PATH="${config.env.DEVENV_STATE}/venv" + VENV_PATH="${config.env.DEVENV_STATE}/${lib.optionalString (cfg.directory != ".") ''"${cfg.directory}/"''}venv" profile_python="$(${readlink} ${package.interpreter})" devenv_interpreter_path="$(${pkgs.coreutils}/bin/cat "$VENV_PATH/.devenv_interpreter" 2> /dev/null || echo false )" @@ -92,12 +92,12 @@ let function _devenv_poetry_install { - local POETRY_INSTALL_COMMAND=(${cfg.poetry.package}/bin/poetry install --no-interaction ${lib.concatStringsSep " " cfg.poetry.install.arguments}) + local POETRY_INSTALL_COMMAND=(${cfg.poetry.package}/bin/poetry install --no-interaction ${lib.concatStringsSep " " cfg.poetry.install.arguments} ${lib.optionalString (cfg.directory != ".") ''--directory=${cfg.directory}''}) # Avoid running "poetry install" for every shell. # Only run it when the "poetry.lock" file or python interpreter has changed. # We do this by storing the interpreter path and a hash of "poetry.lock" in venv. - local ACTUAL_POETRY_CHECKSUM="${package.interpreter}:$(${pkgs.nix}/bin/nix-hash --type sha256 pyproject.toml):$(${pkgs.nix}/bin/nix-hash --type sha256 poetry.lock):''${POETRY_INSTALL_COMMAND[@]}" - local POETRY_CHECKSUM_FILE="$DEVENV_ROOT"/.venv/poetry.lock.checksum + local ACTUAL_POETRY_CHECKSUM="${package.interpreter}:$(${pkgs.nix}/bin/nix-hash --type sha256 "$DEVENV_ROOT"/${lib.optionalString (cfg.directory != ".") ''${cfg.directory}/''}pyproject.toml):$(${pkgs.nix}/bin/nix-hash --type sha256 "$DEVENV_ROOT"/${lib.optionalString (cfg.directory != ".") ''${cfg.directory}/''}poetry.lock):''${POETRY_INSTALL_COMMAND[@]}" + local POETRY_CHECKSUM_FILE="$DEVENV_ROOT"/${lib.optionalString (cfg.directory != ".") ''${cfg.directory}/''}.venv/poetry.lock.checksum if [ -f "$POETRY_CHECKSUM_FILE" ] then read -r EXPECTED_POETRY_CHECKSUM < "$POETRY_CHECKSUM_FILE" @@ -116,7 +116,7 @@ let fi } - if [ ! -f pyproject.toml ] + if [ ! -f "$DEVENV_ROOT"/${lib.optionalString (cfg.directory != ".") ''${cfg.directory}/''}pyproject.toml ] then echo "No pyproject.toml found. Run 'poetry init' to create one." >&2 else @@ -125,7 +125,7 @@ let _devenv_poetry_install ''} ${lib.optionalString cfg.poetry.activate.enable '' - source "$DEVENV_ROOT"/.venv/bin/activate + source "$DEVENV_ROOT"/${lib.optionalString (cfg.directory != ".") ''${cfg.directory}/''}.venv/bin/activate ''} fi ''; @@ -190,6 +190,15 @@ in description = "Whether `pip install` should avoid outputting messages during devenv initialisation."; }; + + directory = lib.mkOption { + type = lib.types.str; + default = "."; + description = '' + The Python project's root directory. Defaults to the root of the devenv project. + ''; + }; + poetry = { enable = lib.mkEnableOption "poetry"; install = { From bed26522794f32cb45ef99824ca3a09b81218e43 Mon Sep 17 00:00:00 2001 From: Matthias Thym Date: Fri, 1 Mar 2024 16:41:50 +0100 Subject: [PATCH 2/9] Add options for poetry install arguments --- src/modules/languages/python.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/modules/languages/python.nix b/src/modules/languages/python.nix index eb624b06c..567676eff 100644 --- a/src/modules/languages/python.nix +++ b/src/modules/languages/python.nix @@ -222,7 +222,17 @@ in groups = lib.mkOption { type = lib.types.listOf lib.types.str; default = [ ]; - description = "Which dependency-groups to install. See `--with`."; + description = "Which dependency groups to install. See `--with`."; + }; + ignoredGroups = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + description = "Which dependency groups to ignore. See `--without`."; + }; + onlyGroups = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + description = "Which dependency groups to exclusively install. See `--only`."; }; extras = lib.mkOption { type = lib.types.listOf lib.types.str; @@ -252,6 +262,8 @@ in lib.optional (!cfg.poetry.install.installRootPackage) "--no-root" ++ lib.optional cfg.poetry.install.quiet "--quiet" ++ lib.optionals (cfg.poetry.install.groups != [ ]) [ "--with" ''"${lib.concatStringsSep "," cfg.poetry.install.groups}"'' ] ++ + lib.optionals (cfg.poetry.install.ignoredGroups != [ ]) [ "--without" ''"${lib.concatStringsSep "," cfg.poetry.install.ignoredGroups}"'' ] ++ + lib.optionals (cfg.poetry.install.onlyGroups != [ ]) [ "--only" ''"${lib.concatStringsSep " " cfg.poetry.install.onlyGroups}"'' ] ++ lib.optionals (cfg.poetry.install.extras != [ ]) [ "--extras" ''"${lib.concatStringsSep " " cfg.poetry.install.extras}"'' ] ++ lib.optional cfg.poetry.install.allExtras "--all-extras"; From ff40f0214551e3408d608f151a27310b4ddc5180 Mon Sep 17 00:00:00 2001 From: Matthias Thym Date: Fri, 1 Mar 2024 16:42:25 +0100 Subject: [PATCH 3/9] Refactoring of comments and option description --- src/modules/languages/python.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/languages/python.nix b/src/modules/languages/python.nix index 567676eff..4994d443b 100644 --- a/src/modules/languages/python.nix +++ b/src/modules/languages/python.nix @@ -39,7 +39,7 @@ let }; initVenvScript = pkgs.writeShellScript "init-venv.sh" '' - # Make sure any tools are not attempting to use the python interpreter from any + # Make sure any tools are not attempting to use the Python interpreter from any # existing virtual environment. For instance if devenv was started within an venv. unset VIRTUAL_ENV @@ -82,11 +82,11 @@ let initPoetryScript = pkgs.writeShellScript "init-poetry.sh" '' function _devenv_init_poetry_venv { - # Make sure any tools are not attempting to use the python interpreter from any + # Make sure any tools are not attempting to use the Python interpreter from any # existing virtual environment. For instance if devenv was started within an venv. unset VIRTUAL_ENV - # Make sure poetry's venv uses the configured python executable. + # Make sure poetry's venv uses the configured Python executable. ${cfg.poetry.package}/bin/poetry env use --no-interaction --quiet ${package.interpreter} } @@ -94,7 +94,7 @@ let { local POETRY_INSTALL_COMMAND=(${cfg.poetry.package}/bin/poetry install --no-interaction ${lib.concatStringsSep " " cfg.poetry.install.arguments} ${lib.optionalString (cfg.directory != ".") ''--directory=${cfg.directory}''}) # Avoid running "poetry install" for every shell. - # Only run it when the "poetry.lock" file or python interpreter has changed. + # Only run it when the "poetry.lock" file or Python interpreter has changed. # We do this by storing the interpreter path and a hash of "poetry.lock" in venv. local ACTUAL_POETRY_CHECKSUM="${package.interpreter}:$(${pkgs.nix}/bin/nix-hash --type sha256 "$DEVENV_ROOT"/${lib.optionalString (cfg.directory != ".") ''${cfg.directory}/''}pyproject.toml):$(${pkgs.nix}/bin/nix-hash --type sha256 "$DEVENV_ROOT"/${lib.optionalString (cfg.directory != ".") ''${cfg.directory}/''}poetry.lock):''${POETRY_INSTALL_COMMAND[@]}" local POETRY_CHECKSUM_FILE="$DEVENV_ROOT"/${lib.optionalString (cfg.directory != ".") ''${cfg.directory}/''}.venv/poetry.lock.checksum @@ -245,7 +245,7 @@ in description = "Whether to install all extras. See `--all-extras`."; }; }; - activate.enable = lib.mkEnableOption "activate the poetry virtual environment automatically"; + activate.enable = lib.mkOption "Whether to activate the poetry virtual environment automatically."; package = lib.mkOption { type = lib.types.package; From 99a2d15d414307841a182cfe9d75d8ce67939b69 Mon Sep 17 00:00:00 2001 From: Matthias Thym Date: Fri, 1 Mar 2024 16:43:15 +0100 Subject: [PATCH 4/9] Remove trailing whitespace --- devenv.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devenv.nix b/devenv.nix index bac8c1bfa..28cd5878c 100644 --- a/devenv.nix +++ b/devenv.nix @@ -116,7 +116,7 @@ cat > docs/languages-all.md < Date: Fri, 1 Mar 2024 17:17:26 +0100 Subject: [PATCH 5/9] Add more options to poetry --- src/modules/languages/python.nix | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/modules/languages/python.nix b/src/modules/languages/python.nix index 4994d443b..5b0c163c2 100644 --- a/src/modules/languages/python.nix +++ b/src/modules/languages/python.nix @@ -190,7 +190,6 @@ in description = "Whether `pip install` should avoid outputting messages during devenv initialisation."; }; - directory = lib.mkOption { type = lib.types.str; default = "."; @@ -214,6 +213,16 @@ in default = false; description = "Whether the root package (your project) should be installed. See `--no-root`"; }; + onlyInstallRootPackage = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Whether to only install the root package (your project) should be installed, but no dependencies. See `--only-root`"; + }; + compile = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Whether `poetry install` should compile Python source files to bytecode."; + }; quiet = lib.mkOption { type = lib.types.bool; default = false; @@ -244,9 +253,17 @@ in default = false; description = "Whether to install all extras. See `--all-extras`."; }; + verbosity = lib.mkOption { + type = lib.types.enum [ "no" "little" "more" "debug" ]; + default = "no"; + description = "What level of verbosity the output of `poetry install` should have."; + }; + }; + activate.enable = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Whether to activate the poetry virtual environment automatically."; }; - activate.enable = lib.mkOption "Whether to activate the poetry virtual environment automatically."; - package = lib.mkOption { type = lib.types.package; default = pkgs.poetry; @@ -259,13 +276,18 @@ in config = lib.mkIf cfg.enable { languages.python.poetry.install.enable = lib.mkIf cfg.poetry.enable (lib.mkDefault true); languages.python.poetry.install.arguments = - lib.optional (!cfg.poetry.install.installRootPackage) "--no-root" ++ + lib.optional cfg.poetry.install.onlyInstallRootPackage "--only-root" ++ + lib.optional (!cfg.poetry.install.installRootPackage && !cfg.poetry.install.onlyInstallRootPackage) "--no-root" ++ + lib.optional cfg.poetry.install.compile "--compile" ++ lib.optional cfg.poetry.install.quiet "--quiet" ++ lib.optionals (cfg.poetry.install.groups != [ ]) [ "--with" ''"${lib.concatStringsSep "," cfg.poetry.install.groups}"'' ] ++ lib.optionals (cfg.poetry.install.ignoredGroups != [ ]) [ "--without" ''"${lib.concatStringsSep "," cfg.poetry.install.ignoredGroups}"'' ] ++ lib.optionals (cfg.poetry.install.onlyGroups != [ ]) [ "--only" ''"${lib.concatStringsSep " " cfg.poetry.install.onlyGroups}"'' ] ++ lib.optionals (cfg.poetry.install.extras != [ ]) [ "--extras" ''"${lib.concatStringsSep " " cfg.poetry.install.extras}"'' ] ++ - lib.optional cfg.poetry.install.allExtras "--all-extras"; + lib.optional cfg.poetry.install.allExtras "--all-extras" ++ + lib.optional (cfg.poetry.install.verbosity == "little") "-v" ++ + lib.optional (cfg.poetry.install.verbosity == "more") "-vv" ++ + lib.optional (cfg.poetry.install.verbosity == "debug") "-vvv"; languages.python.poetry.activate.enable = lib.mkIf cfg.poetry.enable (lib.mkDefault true); From d2778e6608e2538118e3378aa4d67c7787fa93ae Mon Sep 17 00:00:00 2001 From: Matthias Thym Date: Mon, 4 Mar 2024 11:03:41 +0100 Subject: [PATCH 6/9] Update python-poetry example --- examples/python-poetry/devenv.nix | 21 +++++++++++++++++++-- examples/python-poetry/devenv.yaml | 7 +++++++ examples/python-poetry/pyproject.toml | 16 +++++++++------- 3 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 examples/python-poetry/devenv.yaml diff --git a/examples/python-poetry/devenv.nix b/examples/python-poetry/devenv.nix index 97fb33a07..b9595ba83 100644 --- a/examples/python-poetry/devenv.nix +++ b/examples/python-poetry/devenv.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, config, ... }: +{ pkgs, config, ... }: { packages = [ @@ -15,6 +15,23 @@ languages.python = { enable = true; - poetry.enable = true; + poetry = { + enable = true; + install = { + enable = true; + installRootPackage = false; + onlyInstallRootPackage = false; + compile = false; + quiet = false; + groups = [ ]; + ignoredGroups = [ ]; + onlyGroups = [ ]; + extras = [ ]; + allExtras = false; + verbosity = "no"; + }; + activate.enable = true; + package = pkgs.poetry; + }; }; } diff --git a/examples/python-poetry/devenv.yaml b/examples/python-poetry/devenv.yaml new file mode 100644 index 000000000..15728c9fc --- /dev/null +++ b/examples/python-poetry/devenv.yaml @@ -0,0 +1,7 @@ +--- + +inputs: + nixpkgs: + url: github:NixOS/nixpkgs/nixpkgs-unstable + nixpkgs-python: + url: github:cachix/nixpkgs-python diff --git a/examples/python-poetry/pyproject.toml b/examples/python-poetry/pyproject.toml index b16b3d14d..f6e9ff20a 100644 --- a/examples/python-poetry/pyproject.toml +++ b/examples/python-poetry/pyproject.toml @@ -1,15 +1,17 @@ +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + [tool.poetry] name = "python-poetry" -version = "0.1.0" +version = "0.2.0" description = "" -authors = ["Bob van der Linden "] +authors = [ + "Bob van der Linden ", + "Matthias Thym " +] readme = "README.md" [tool.poetry.dependencies] python = "^3.10" numpy = "^1.24.1" - - -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" From d11cf576fa80d2644b165db62fd62dfb34da567f Mon Sep 17 00:00:00 2001 From: Matthias Thym Date: Mon, 4 Mar 2024 11:12:01 +0100 Subject: [PATCH 7/9] Add example and tests for Python directory option --- examples/python-directory/.gitignore | 5 +++++ examples/python-directory/.test.sh | 10 ++++++++++ examples/python-directory/devenv.nix | 13 +++++++++++++ examples/python-directory/devenv.yaml | 7 +++++++ .../python-directory/directory/pyproject.toml | 17 +++++++++++++++++ 5 files changed, 52 insertions(+) create mode 100644 examples/python-directory/.gitignore create mode 100755 examples/python-directory/.test.sh create mode 100644 examples/python-directory/devenv.nix create mode 100644 examples/python-directory/devenv.yaml create mode 100644 examples/python-directory/directory/pyproject.toml diff --git a/examples/python-directory/.gitignore b/examples/python-directory/.gitignore new file mode 100644 index 000000000..715bef439 --- /dev/null +++ b/examples/python-directory/.gitignore @@ -0,0 +1,5 @@ + +# Devenv +.devenv* +devenv.local.nix + diff --git a/examples/python-directory/.test.sh b/examples/python-directory/.test.sh new file mode 100755 index 000000000..47c0c8436 --- /dev/null +++ b/examples/python-directory/.test.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -exu +POETRY_VENV="$PWD/directory/.venv" +[ -d "$POETRY_VENV" ] +[ "$(poetry env info --path)" = "$POETRY_VENV" ] +[ "$(command -v python)" = "$POETRY_VENV/bin/python" ] +python --version +poetry --version +poetry run python -c 'import requests' +python -c 'import requests' diff --git a/examples/python-directory/devenv.nix b/examples/python-directory/devenv.nix new file mode 100644 index 000000000..db93b10e0 --- /dev/null +++ b/examples/python-directory/devenv.nix @@ -0,0 +1,13 @@ +{ pkgs, config, ... }: + +{ + languages.python = { + enable = true; + directory = "./directory"; + poetry = { + enable = true; + install.enable = true; + activate.enable = true; + }; + }; +} diff --git a/examples/python-directory/devenv.yaml b/examples/python-directory/devenv.yaml new file mode 100644 index 000000000..15728c9fc --- /dev/null +++ b/examples/python-directory/devenv.yaml @@ -0,0 +1,7 @@ +--- + +inputs: + nixpkgs: + url: github:NixOS/nixpkgs/nixpkgs-unstable + nixpkgs-python: + url: github:cachix/nixpkgs-python diff --git a/examples/python-directory/directory/pyproject.toml b/examples/python-directory/directory/pyproject.toml new file mode 100644 index 000000000..99d95e926 --- /dev/null +++ b/examples/python-directory/directory/pyproject.toml @@ -0,0 +1,17 @@ +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + +[tool.poetry] +name = "python-directory" +version = "0.1.0" +description = "" +authors = [ + "Bob van der Linden ", + "Matthias Thym " +] +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.11" +requests = "^2.30" From 2ff8144eda7dee503abf1db9922d53d84f462535 Mon Sep 17 00:00:00 2001 From: Matthias Thym Date: Mon, 4 Mar 2024 20:40:33 +0100 Subject: [PATCH 8/9] Use `config.devenv.root` as default for Python project directory --- src/modules/languages/python.nix | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/modules/languages/python.nix b/src/modules/languages/python.nix index 5b0c163c2..8e1f177f5 100644 --- a/src/modules/languages/python.nix +++ b/src/modules/languages/python.nix @@ -43,7 +43,7 @@ let # existing virtual environment. For instance if devenv was started within an venv. unset VIRTUAL_ENV - VENV_PATH="${config.env.DEVENV_STATE}/${lib.optionalString (cfg.directory != ".") ''"${cfg.directory}/"''}venv" + VENV_PATH="${config.env.DEVENV_STATE}/${lib.optionalString (cfg.directory != config.devenv.root) ''"${cfg.directory}/"''}venv" profile_python="$(${readlink} ${package.interpreter})" devenv_interpreter_path="$(${pkgs.coreutils}/bin/cat "$VENV_PATH/.devenv_interpreter" 2> /dev/null || echo false )" @@ -92,12 +92,12 @@ let function _devenv_poetry_install { - local POETRY_INSTALL_COMMAND=(${cfg.poetry.package}/bin/poetry install --no-interaction ${lib.concatStringsSep " " cfg.poetry.install.arguments} ${lib.optionalString (cfg.directory != ".") ''--directory=${cfg.directory}''}) + local POETRY_INSTALL_COMMAND=(${cfg.poetry.package}/bin/poetry install --no-interaction ${lib.concatStringsSep " " cfg.poetry.install.arguments} ${lib.optionalString (cfg.directory != config.devenv.root) ''--directory=${cfg.directory}''}) # Avoid running "poetry install" for every shell. # Only run it when the "poetry.lock" file or Python interpreter has changed. # We do this by storing the interpreter path and a hash of "poetry.lock" in venv. - local ACTUAL_POETRY_CHECKSUM="${package.interpreter}:$(${pkgs.nix}/bin/nix-hash --type sha256 "$DEVENV_ROOT"/${lib.optionalString (cfg.directory != ".") ''${cfg.directory}/''}pyproject.toml):$(${pkgs.nix}/bin/nix-hash --type sha256 "$DEVENV_ROOT"/${lib.optionalString (cfg.directory != ".") ''${cfg.directory}/''}poetry.lock):''${POETRY_INSTALL_COMMAND[@]}" - local POETRY_CHECKSUM_FILE="$DEVENV_ROOT"/${lib.optionalString (cfg.directory != ".") ''${cfg.directory}/''}.venv/poetry.lock.checksum + local ACTUAL_POETRY_CHECKSUM="${package.interpreter}:$(${pkgs.nix}/bin/nix-hash --type sha256 "$DEVENV_ROOT"/${lib.optionalString (cfg.directory != config.devenv.root) ''${cfg.directory}/''}pyproject.toml):$(${pkgs.nix}/bin/nix-hash --type sha256 "$DEVENV_ROOT"/${lib.optionalString (cfg.directory != config.devenv.root) ''${cfg.directory}/''}poetry.lock):''${POETRY_INSTALL_COMMAND[@]}" + local POETRY_CHECKSUM_FILE="$DEVENV_ROOT"/${lib.optionalString (cfg.directory != config.devenv.root) ''${cfg.directory}/''}.venv/poetry.lock.checksum if [ -f "$POETRY_CHECKSUM_FILE" ] then read -r EXPECTED_POETRY_CHECKSUM < "$POETRY_CHECKSUM_FILE" @@ -116,7 +116,7 @@ let fi } - if [ ! -f "$DEVENV_ROOT"/${lib.optionalString (cfg.directory != ".") ''${cfg.directory}/''}pyproject.toml ] + if [ ! -f "$DEVENV_ROOT"/${lib.optionalString (cfg.directory != config.devenv.root) ''${cfg.directory}/''}pyproject.toml ] then echo "No pyproject.toml found. Run 'poetry init' to create one." >&2 else @@ -125,7 +125,7 @@ let _devenv_poetry_install ''} ${lib.optionalString cfg.poetry.activate.enable '' - source "$DEVENV_ROOT"/${lib.optionalString (cfg.directory != ".") ''${cfg.directory}/''}.venv/bin/activate + source "$DEVENV_ROOT"/${lib.optionalString (cfg.directory != config.devenv.root) ''${cfg.directory}/''}.venv/bin/activate ''} fi ''; @@ -192,7 +192,7 @@ in directory = lib.mkOption { type = lib.types.str; - default = "."; + default = config.devenv.root; description = '' The Python project's root directory. Defaults to the root of the devenv project. ''; From 8c97d190eb80a5437c41b0ce748663d66db43574 Mon Sep 17 00:00:00 2001 From: Matthias Thym Date: Tue, 5 Mar 2024 08:58:00 +0100 Subject: [PATCH 9/9] Apply suggestions --- examples/python-directory/devenv.yaml | 2 -- examples/python-poetry/devenv.yaml | 2 -- src/modules/languages/python.nix | 19 +++++++++++-------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/examples/python-directory/devenv.yaml b/examples/python-directory/devenv.yaml index 15728c9fc..a32e623e1 100644 --- a/examples/python-directory/devenv.yaml +++ b/examples/python-directory/devenv.yaml @@ -1,5 +1,3 @@ ---- - inputs: nixpkgs: url: github:NixOS/nixpkgs/nixpkgs-unstable diff --git a/examples/python-poetry/devenv.yaml b/examples/python-poetry/devenv.yaml index 15728c9fc..a32e623e1 100644 --- a/examples/python-poetry/devenv.yaml +++ b/examples/python-poetry/devenv.yaml @@ -1,5 +1,3 @@ ---- - inputs: nixpkgs: url: github:NixOS/nixpkgs/nixpkgs-unstable diff --git a/src/modules/languages/python.nix b/src/modules/languages/python.nix index 8e1f177f5..9f66f240c 100644 --- a/src/modules/languages/python.nix +++ b/src/modules/languages/python.nix @@ -173,6 +173,17 @@ in example = "3.11 or 3.11.2"; }; + directory = lib.mkOption { + type = lib.types.str; + default = config.devenv.root; + defaultText = lib.literalExpression "config.devenv.root"; + description = '' + The Python project's root directory. Defaults to the root of the devenv project. + Can be an absolute path or one relative to the root of the devenv project. + ''; + example = "./directory"; + }; + venv.enable = lib.mkEnableOption "Python virtual environment"; venv.requirements = lib.mkOption { @@ -190,14 +201,6 @@ in description = "Whether `pip install` should avoid outputting messages during devenv initialisation."; }; - directory = lib.mkOption { - type = lib.types.str; - default = config.devenv.root; - description = '' - The Python project's root directory. Defaults to the root of the devenv project. - ''; - }; - poetry = { enable = lib.mkEnableOption "poetry"; install = {