diff --git a/examples/python/science/default.nix b/examples/python/science/default.nix index dbe96073..51aea373 100644 --- a/examples/python/science/default.nix +++ b/examples/python/science/default.nix @@ -1,11 +1,23 @@ -{pkgs, ...}: { +{ + pkgs, + config, + ... +}: let + cfg-science-example = config.kernel.python.science-example; +in { kernel.python.science-example = { enable = true; - extraPackages = ps: [ - ps.numpy - ps.scipy - # issue with matplotlib - # ps.matplotlib - ]; + env = cfg-science-example.nixpkgs.python3.withPackages (ps: + with ps; [ + ps.ipykernel + ps.scipy + ps.matplotlib + ]); + # extraPackages = ps: [ + # ps.numpy + # ps.scipy + # # issue with matplotlib + # # ps.matplotlib + # ]; }; } diff --git a/examples/python/science/test.ipynb b/examples/python/science/test.ipynb index 35a807a5..7bbb94f5 100644 --- a/examples/python/science/test.ipynb +++ b/examples/python/science/test.ipynb @@ -8,7 +8,8 @@ "outputs": [], "source": [ "import numpy as np\n", - "import scipy as sp" + "import scipy as sp\n", + "import matplotlib as mpl" ] }, { diff --git a/lib/jupyter.nix b/lib/jupyter.nix index 0507da84..472ba5b4 100644 --- a/lib/jupyter.nix +++ b/lib/jupyter.nix @@ -184,7 +184,15 @@ */ mkJupyterlabEval = customModule: pkgs.lib.evalModules { - specialArgs = {inherit self system mkJupyterlab mkKernel;}; + specialArgs = { + inherit + self + system + mkJupyterlab + mkKernel + ; + mkPoetryKernel = import ../modules/poetry.nix; + }; modules = lib.flatten ( [../modules] ++ lib.optional (customModule != null) customModule diff --git a/modules/kernels/bash/default.nix b/modules/kernels/bash/default.nix index fdb8f620..939b8155 100644 --- a/modules/kernels/bash/default.nix +++ b/modules/kernels/bash/default.nix @@ -1,20 +1,18 @@ { + mkPoetryKernel, config, - system, - mkKernel, ... -} @ args: -import ./../../poetry.nix { - inherit mkKernel; - - argvKernelName = "bash_kernel"; - codemirrorMode = "shell"; - language = "bash"; - - kernelName = "bash"; - requiredRuntimePackages = [ - config.nixpkgs.bashInteractive - config.nixpkgs.coreutils +}: { + imports = [ + (mkPoetryKernel { + argvKernelName = "bash_kernel"; + codemirrorMode = "shell"; + language = "bash"; + kernelName = "bash"; + requiredRuntimePackages = [ + config.nixpkgs.bashInteractive + config.nixpkgs.coreutils + ]; + }) ]; } -args diff --git a/modules/kernels/c/default.nix b/modules/kernels/c/default.nix index 590ef0fc..d9fc1a7c 100644 --- a/modules/kernels/c/default.nix +++ b/modules/kernels/c/default.nix @@ -1,19 +1,17 @@ { + mkPoetryKernel, config, - system, - mkKernel, ... -} @ args: -import ./../../poetry.nix { - inherit mkKernel; - - argvKernelName = "jupyter_c_kernel"; - codemirrorMode = "clike"; - language = "c"; - - requiredRuntimePackages = [ - config.nixpkgs.stdenv.cc +}: { + imports = [ + (mkPoetryKernel { + argvKernelName = "jupyter_c_kernel"; + codemirrorMode = "clike"; + language = "c"; + requiredRuntimePackages = [ + config.nixpkgs.stdenv.cc + ]; + kernelName = "c"; + }) ]; - kernelName = "c"; } -args diff --git a/modules/kernels/elm/default.nix b/modules/kernels/elm/default.nix index 6c3367bc..222968bb 100644 --- a/modules/kernels/elm/default.nix +++ b/modules/kernels/elm/default.nix @@ -1,19 +1,17 @@ { + mkPoetryKernel, config, - system, - mkKernel, ... -} @ args: -import ./../../poetry.nix { - inherit mkKernel; - - argvKernelName = "elm_kernel"; - codemirrorMode = "elm"; - language = "elm"; - - requiredRuntimePackages = [ - config.nixpkgs.elmPackages.elm +}: { + imports = [ + (mkPoetryKernel { + argvKernelName = "elm_kernel"; + codemirrorMode = "elm"; + language = "elm"; + requiredRuntimePackages = [ + config.nixpkgs.elmPackages.elm + ]; + kernelName = "elm"; + }) ]; - kernelName = "elm"; } -args diff --git a/modules/kernels/postgres/default.nix b/modules/kernels/postgres/default.nix index 9accb266..36484b97 100644 --- a/modules/kernels/postgres/default.nix +++ b/modules/kernels/postgres/default.nix @@ -1,16 +1,14 @@ { + mkPoetryKernel, config, - system, - mkKernel, ... -} @ args: -import ./../../poetry.nix { - inherit mkKernel; - - argvKernelName = "postgres_kernel"; - codemirrorMode = "pgsql"; - language = "postgres"; - - kernelName = "postgres"; +}: { + imports = [ + (mkPoetryKernel { + argvKernelName = "postgres_kernel"; + codemirrorMode = "pgsql"; + language = "postgres"; + kernelName = "postgres"; + }) + ]; } -args diff --git a/modules/kernels/python/default.nix b/modules/kernels/python/default.nix index a5e6ffe6..1e6e4d6f 100644 --- a/modules/kernels/python/default.nix +++ b/modules/kernels/python/default.nix @@ -1,15 +1,12 @@ -{ - config, - mkKernel, - ... -} @ args: -import ./../../poetry.nix { - inherit mkKernel; - - argvKernelName = "ipykernel_launcher"; - codemirrorMode = "python"; - language = "python"; - - kernelName = "python"; +{mkPoetryKernel, ...}: { + imports = [ + ( + mkPoetryKernel { + argvKernelName = "ipykernel_launcher"; + codemirrorMode = "python"; + language = "python"; + kernelName = "python"; + } + ) + ]; } -args diff --git a/modules/kernels/zsh/default.nix b/modules/kernels/zsh/default.nix index 6c8c056e..5cd06d7a 100644 --- a/modules/kernels/zsh/default.nix +++ b/modules/kernels/zsh/default.nix @@ -1,20 +1,18 @@ { + mkPoetryKernel, config, - system, - mkKernel, ... -} @ args: -import ./../../poetry.nix { - inherit mkKernel; - - argvKernelName = "zsh_jupyter_kernel"; - codemirrorMode = "shell"; - language = "zsh"; - - requiredRuntimePackages = [ - config.nixpkgs.zsh - config.nixpkgs.coreutils +}: { + imports = [ + (mkPoetryKernel { + argvKernelName = "zsh_jupyter_kernel"; + codemirrorMode = "shell"; + language = "zsh"; + requiredRuntimePackages = [ + config.nixpkgs.zsh + config.nixpkgs.coreutils + ]; + kernelName = "zsh"; + }) ]; - kernelName = "zsh"; } -args diff --git a/modules/poetry.nix b/modules/poetry.nix index 03e363d8..e456af13 100644 --- a/modules/poetry.nix +++ b/modules/poetry.nix @@ -1,7 +1,6 @@ { kernelName, requiredRuntimePackages ? [], - mkKernel, argvKernelName, codemirrorMode, language, @@ -10,6 +9,7 @@ system, config, lib, + mkKernel, ... }: let inherit (lib) types;