Skip to content

Commit

Permalink
modules: add python options to specify the python environment
Browse files Browse the repository at this point in the history
  • Loading branch information
GaetanLepage committed Jan 6, 2024
1 parent 5574515 commit b1198f7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions modules/output.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
lib,
config,
pkgs,
...
}:
with lib; let
Expand Down Expand Up @@ -38,6 +39,24 @@ in {
description = "Extra packages to be made available to neovim";
};

python = {
package = mkOption {
type = types.package;
default = pkgs.python3;
description = "";
};

extraPythonPackages = mkOption {
type = with types; functionTo (listOf package);
default = p: [];
defaultText = literalExpression "p: with p; [ ]";
description = "Python packages to add to the `PYTHONPATH` of neovim.";
example = lib.literalExpression ''
p: [ p.numpy ]
'';
};
};

extraConfigLua = mkOption {
type = types.lines;
default = "";
Expand Down
10 changes: 10 additions & 0 deletions tests/test-sources/examples.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{pkgs, ...}: {
plain = {};

python-packages = {
python = {
package = pkgs.python3;
extraPythonPackages = p:
with p; [
numpy
];
};
};

simple-plugin = {
extraPlugins = [pkgs.vimPlugins.vim-surround];
};
Expand Down
7 changes: 7 additions & 0 deletions wrappers/modules/output.nix
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ in {
inherit (config) viAlias vimAlias;
# inherit customRC;
plugins = normalizedPlugins;

# Python 3 environment
python3Env = let
python = config.python.package;
inherit (config.python) extraPythonPackages;
in
python.withPackages extraPythonPackages;
}
# Necessary to make sure the runtime path is set properly in NixOS 22.05,
# or more generally before the commit:
Expand Down

0 comments on commit b1198f7

Please sign in to comment.