jupyter-console: expose as a tool for launching kernels

This commit is contained in:
Tom McLaughlin 2023-07-25 01:22:45 -07:00 committed by thomasjm
parent be7925045a
commit 0342a5194b
6 changed files with 91 additions and 17 deletions

@ -8,8 +8,11 @@
, imagemagick
}:
# To test:
# $(nix-build --no-out-link -E 'with import <nixpkgs> {}; jupyter.override { definitions = { clojure = clojupyter.definition; }; }')/bin/jupyter-notebook
# Jupyter console:
# nix run --impure --expr 'with import <nixpkgs> {}; jupyter-console.withSingleKernel clojupyter.definition'
# Jupyter notebook:
# nix run --impure --expr 'with import <nixpkgs> {}; jupyter.override { definitions.clojure = clojupyter.definition; }'
let
cljdeps = import ./deps.nix { inherit pkgs; };

@ -2,16 +2,41 @@
, bundlerApp
}:
bundlerApp {
pname = "iruby";
gemdir = ./.;
exes = [ "iruby" ];
# Jupyter console:
# nix run --impure --expr 'with import <nixpkgs> {}; jupyter-console.withSingleKernel iruby.definition'
meta = with lib; {
description = "Ruby kernel for Jupyter";
homepage = "https://github.com/SciRuby/iruby";
license = licenses.mit;
maintainers = [ maintainers.costrouc ];
platforms = platforms.unix;
# Jupyter notebook:
# nix run --impure --expr 'with import <nixpkgs> {}; jupyter.override { definitions.iruby = iruby.definition; }'
let
self = bundlerApp {
pname = "iruby";
gemdir = ./.;
exes = [ "iruby" ];
passthru = {
definition = {
displayName = "IRuby";
argv = [
"${self}/bin/iruby"
"kernel"
"{connection_file}"
];
language = "ruby";
logo32 = null;
logo64 = null;
};
};
meta = {
description = "Ruby kernel for Jupyter";
homepage = "https://github.com/SciRuby/iruby";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ costrouc thomasjm ];
platforms = lib.platforms.unix;
};
};
}
in
self

@ -7,8 +7,11 @@
, python3
}:
# To test:
# $(nix-build -E 'with import <nixpkgs> {}; jupyter.override { definitions = { octave = octave-kernel.definition; }; }')/bin/jupyter-notebook
# Jupyter console:
# nix run --impure --expr 'with import <nixpkgs> {}; jupyter-console.withSingleKernel octave-kernel.definition'
# Jupyter notebook:
# nix run --impure --expr 'with import <nixpkgs> {}; jupyter.override { definitions.octave = octave-kernel.definition; }'
let
kernel = callPackage ./kernel.nix {

@ -2,8 +2,12 @@
, wolfram-engine
}:
# To test:
# $(nix-build -E 'with import ./. {}; jupyter.override { definitions = { wolfram = wolfram-for-jupyter-kernel.definition; }; }')/bin/jupyter-notebook
# Jupyter console:
# nix run --impure --expr 'with import <nixpkgs> {}; jupyter-console.withSingleKernel wolfram-for-jupyter-kernel.definition'
# Jupyter notebook:
# nix run --impure --expr 'with import <nixpkgs> {}; jupyter.override { definitions.wolfram = wolfram-for-jupyter-kernel.definition; }'
let kernel = callPackage ./kernel.nix {};
in {
definition = {

@ -0,0 +1,37 @@
{ python3
, jupyter-kernel
, lib
}:
let
mkConsole = {
definitions ? jupyter-kernel.default
, kernel ? null
}:
(python3.buildEnv.override {
extraLibs = [ python3.pkgs.jupyter-console ];
makeWrapperArgs = [
"--set JUPYTER_PATH ${jupyter-kernel.create { inherit definitions; }}"
] ++ lib.optionals (kernel != null) [
"--add-flags --kernel"
"--add-flags ${kernel}"
];
}).overrideAttrs (oldAttrs: {
# To facilitate running nix run .#jupyter-console
meta = oldAttrs.meta // { mainProgram = "jupyter-console"; };
});
in
{
# Build a console derivation with an arbitrary set of definitions, and an optional kernel to use.
# If the kernel argument is not supplied, Jupyter console will pick a kernel to run from the ones
# available on the system.
inherit mkConsole;
# An ergonomic way to start a console with a single kernel.
withSingleKernel = definition: mkConsole {
definitions = lib.listToAttrs [(lib.nameValuePair definition.language definition)];
kernel = definition.language;
};
}

@ -9663,6 +9663,8 @@ with pkgs;
};
};
jupyter-console = callPackage ../applications/editors/jupyter/console.nix { };
jupyter-kernel = callPackage ../applications/editors/jupyter/kernel.nix { };
justify = callPackage ../tools/text/justify { };