Skip to content

Commit

Permalink
refactor: add mkPoertyKernel
Browse files Browse the repository at this point in the history
  • Loading branch information
GTrunSec committed Oct 2, 2023
1 parent 5eec2f6 commit db5bdcd
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 94 deletions.
26 changes: 19 additions & 7 deletions examples/python/science/default.nix
Original file line number Diff line number Diff line change
@@ -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
# ];
};
}
3 changes: 2 additions & 1 deletion examples/python/science/test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"outputs": [],
"source": [
"import numpy as np\n",
"import scipy as sp"
"import scipy as sp\n",
"import matplotlib as mpl"
]
},
{
Expand Down
10 changes: 9 additions & 1 deletion lib/jupyter.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 13 additions & 15 deletions modules/kernels/bash/default.nix
Original file line number Diff line number Diff line change
@@ -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
26 changes: 12 additions & 14 deletions modules/kernels/c/default.nix
Original file line number Diff line number Diff line change
@@ -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
26 changes: 12 additions & 14 deletions modules/kernels/elm/default.nix
Original file line number Diff line number Diff line change
@@ -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
22 changes: 10 additions & 12 deletions modules/kernels/postgres/default.nix
Original file line number Diff line number Diff line change
@@ -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
25 changes: 11 additions & 14 deletions modules/kernels/python/default.nix
Original file line number Diff line number Diff line change
@@ -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
28 changes: 13 additions & 15 deletions modules/kernels/zsh/default.nix
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion modules/poetry.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
kernelName,
requiredRuntimePackages ? [],
mkKernel,
argvKernelName,
codemirrorMode,
language,
Expand All @@ -10,6 +9,7 @@
system,
config,
lib,
mkKernel,
...
}: let
inherit (lib) types;
Expand Down

0 comments on commit db5bdcd

Please sign in to comment.