2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchPypi,
|
|
|
|
flit-core,
|
|
|
|
ipykernel,
|
|
|
|
python,
|
|
|
|
pexpect,
|
|
|
|
bashInteractive,
|
|
|
|
substituteAll,
|
2023-11-16 04:20:00 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "bash-kernel";
|
2024-01-02 11:29:13 +00:00
|
|
|
version = "0.9.3";
|
2023-11-16 04:20:00 +00:00
|
|
|
pyproject = true;
|
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
pname = "bash_kernel";
|
|
|
|
inherit version;
|
2024-01-02 11:29:13 +00:00
|
|
|
hash = "sha256-n3oDgRyn2csfv/gIIjfPBFC5cYIlL9C4BYeha2XmbVg=";
|
2023-11-16 04:20:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
(substituteAll {
|
|
|
|
src = ./bash-path.patch;
|
2024-05-15 15:35:15 +00:00
|
|
|
bash = lib.getExe bashInteractive;
|
2023-11-16 04:20:00 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
nativeBuildInputs = [ flit-core ];
|
2023-11-16 04:20:00 +00:00
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
ipykernel
|
|
|
|
pexpect
|
|
|
|
];
|
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
export HOME=$TMPDIR
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
${python.pythonOnBuildForHost.interpreter} -m bash_kernel.install --prefix $out
|
|
|
|
'';
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
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)
|
2024-06-05 15:53:02 +00:00
|
|
|
${python.withPackages (ps: [ ps.papermill ])}/bin/papermill --kernel bash ${./test.ipynb} out.ipynb
|
2024-05-15 15:35:15 +00:00
|
|
|
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
2023-11-16 04:20:00 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Bash Kernel for Jupyter";
|
|
|
|
homepage = "https://github.com/takluyver/bash_kernel";
|
|
|
|
changelog = "https://github.com/takluyver/bash_kernel/releases/tag/${version}";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
maintainers = with maintainers; [ zimbatm ];
|
|
|
|
};
|
|
|
|
}
|