From 16f4076c7056288c99cbecceadf98b81dc32efc0 Mon Sep 17 00:00:00 2001 From: Augustin Borsu Date: Sun, 21 Jan 2018 19:11:33 +0100 Subject: [PATCH] jupyter-kernel: init This is a meta package for creating a jupyter notebook kernel definition folder. It must be used in conjunction with jupyter or jupyterhub to make different environements availables. --- pkgs/applications/editors/jupyter/kernel.nix | 74 ++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 76 insertions(+) create mode 100644 pkgs/applications/editors/jupyter/kernel.nix diff --git a/pkgs/applications/editors/jupyter/kernel.nix b/pkgs/applications/editors/jupyter/kernel.nix new file mode 100644 index 000000000000..cdb6b6212bd3 --- /dev/null +++ b/pkgs/applications/editors/jupyter/kernel.nix @@ -0,0 +1,74 @@ +{ lib, stdenv, python3}: + +let + + default = { + python3 = let + env = (python3.withPackages (ps: with ps; [ ipykernel ])); + in { + displayName = "Python 3"; + argv = [ + "${env.interpreter}" + "-m" + "ipykernel_launcher" + "-f" + "{connection_file}" + ]; + language = "python"; + logo32 = "${env.sitePackages}/ipykernel/resources/logo-32x32.png"; + logo64 = "${env.sitePackages}/ipykernel/resources/logo-64x64.png"; + }; + }; + +in +{ + inherit default; + + # Definitions is an attribute set. + + create = { definitions ? default }: with lib; stdenv.mkDerivation rec { + + name = "jupyter-kernels"; + + src = "/dev/null"; + + unpackCmd = "mkdir jupyter_kernels"; + + installPhase = '' + mkdir kernels + + ${concatStringsSep "\n" (mapAttrsToList (kernelName: kernel: + let + config = builtins.toJSON { + display_name = if (kernel.displayName != "") + then kernel.displayName + else kernelName; + argv = kernel.argv; + language = kernel.language; + }; + logo32 = + if (kernel.logo32 != null) + then "ln -s ${kernel.logo32} 'kernels/${kernelName}/logo-32x32.png';" + else ""; + logo64 = + if (kernel.logo64 != null) + then "ln -s ${kernel.logo64} 'kernels/${kernelName}/logo-64x64.png';" + else ""; + in '' + mkdir 'kernels/${kernelName}'; + echo '${config}' > 'kernels/${kernelName}/kernel.json'; + ${logo32} + ${logo64} + '') definitions)} + + mkdir $out + cp -r kernels $out + ''; + + meta = { + description = "Wrapper to create jupyter notebook kernel definitions"; + homepage = http://jupyter.org/; + maintainers = with maintainers; [ aborsu ]; + }; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a434aee6c189..472155ac265a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3383,6 +3383,8 @@ with pkgs; jupp = callPackage ../applications/editors/jupp { }; + jupyter-kernel = callPackage ../applications/editors/jupyter/kernel.nix { }; + jwhois = callPackage ../tools/networking/jwhois { }; k2pdfopt = callPackage ../applications/misc/k2pdfopt { };