Skip to content

Commit

Permalink
bash-kernel: fix and add smoke test
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed May 14, 2024
1 parent 714c88b commit 0427fa6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
20 changes: 16 additions & 4 deletions pkgs/development/python-modules/bash-kernel/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
, ipykernel
, python
, pexpect
, bash
, bashInteractive
, substituteAll
}:

Expand All @@ -24,7 +24,7 @@ buildPythonPackage rec {
patches = [
(substituteAll {
src = ./bash-path.patch;
bash = lib.getExe bash;
bash = lib.getExe bashInteractive;
})
];

Expand All @@ -45,8 +45,20 @@ buildPythonPackage rec {
${python.pythonOnBuildForHost.interpreter} -m bash_kernel.install --prefix $out
'';

# no tests
doCheck = false;
checkPhase = ''
runHook preCheck
# Create a JUPYTER_PATH with the kernelspec
export JUPYTER_PATH=$(mktemp -d)
mkdir -p $JUPYTER_PATH/kernels/bash
echo '{ "language": "bash", "argv": [ "${python}/bin/python", "-m", "bash_kernel", "-f", "{connection_file}" ] }' > $JUPYTER_PATH/kernels/bash/kernel.json
# Evaluate a test notebook with papermill
cd $(mktemp -d)
${python.withPackages (ps: [ps.papermill])}/bin/papermill --kernel bash ${./test.ipynb} out.ipynb
runHook postCheck
'';

meta = with lib; {
description = "Bash Kernel for Jupyter";
Expand Down
26 changes: 26 additions & 0 deletions pkgs/development/python-modules/bash-kernel/test.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"echo hi"
]
}
],
"metadata": {
"kernel_info": {
"display_name": "Unknown",
"name": "bash"
},
"language_info": {
"file_extension": ".ipynb",
"name": "bash",
"version": "5.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 0427fa6

Please sign in to comment.