Skip to content

Commit

Permalink
Organizing settings for Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Sep 25, 2024
1 parent 4bcbb15 commit f30464d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
5 changes: 3 additions & 2 deletions modules/kernels/python/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
, settingsSchema
}:

with { inherit (settings) packages attrs extensions; };
with { inherit (settings) packages; };
with { inherit (settings.interface) attrs extensions; };

let
common = callPackage ../common.nix {};
Expand Down Expand Up @@ -56,7 +57,7 @@ symlinkJoin {
(callPackage ./kernel.nix {
python = pythonToUse;
inherit displayName kernelName attrs extensions;
enableVariableInspector = settings.enableVariableInspector;
enableVariableInspector = settings.misc.enableVariableInspector;
})

pythonToUse
Expand Down
16 changes: 10 additions & 6 deletions modules/kernels/python/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ let

python3Package = packageOption;

attrs = mkOption {
interface.attrs = mkOption {
example = "Notebook attributes";
description = "Notebook cells that have these attributes will match this kernel, allowing it to run the code.";
type = types.listOf types.str;
default = ["python"];
};

extensions = mkOption {
interface.extensions = mkOption {
example = "File extensions";
description = "Files with these extensions will match against this kernel, allowing you to run the code as if it were a Jupyter cell.";
type = types.listOf types.str;
default = ["py"];
};
Expand Down Expand Up @@ -70,14 +73,15 @@ let
default = false;
};

permitUserSite = mkOption {
misc.permitUserSite = mkOption {
example = "Permit user site-packages";
description = "Skip setting the PYTHONNOUSERSITE variable. This will allow your Python code to import local packages (e.g. from ~/.local/lib). This is useful if you want to use pip to install Python packages independently of Nix.";
type = types.bool;
default = false;
};
enableVariableInspector = mkOption {
description = "Enable the variable inspector";
misc.enableVariableInspector = mkOption {
example = "Enable the variable inspector";
description = "This will show a summary of the currently defined variables in the UI.";
type = types.bool;
default = true;
};
Expand Down
4 changes: 2 additions & 2 deletions sample_environments/mega.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ codedown.makeEnvironment {

kernels.python3.enable = true;
kernels.python3.packages = ["matplotlib" "scipy" "rope"];
kernels.python3.permitUserSite = false;
kernels.python3.lsp.jedi.enable = true;
kernels.python3.lsp.pyright.enable = true;
kernels.python3.lsp.pylint.enable = true;
kernels.python3.lsp.flake8.enable = true;
kernels.python3.lsp.pycodestyle.enable = true;
kernels.python3.lsp.python-lsp-server.enable = true;
kernels.python3.misc.permitUserSite = false;

# kernels.pypy3.enable = true;
# kernels.pypy3.permitUserSite = false;
# kernels.pypy3.misc.permitUserSite = false;

kernels.ruby.enable = true;

Expand Down
4 changes: 2 additions & 2 deletions sample_environments/python3.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ codedown.makeEnvironment {
"rope"
];

kernels.python3.permitUserSite = false;

kernels.python3.lsp = {
jedi.enable = true;
pyright.enable = true;
Expand All @@ -21,4 +19,6 @@ codedown.makeEnvironment {
pycodestyle.enable = true;
python-lsp-server.enable = true;
};

kernels.python3.misc.permitUserSite = false;
}

0 comments on commit f30464d

Please sign in to comment.