1 { lib, stdenv, python3}:
7 env = (python3.withPackages (ps: with ps; [ ipykernel ]));
9 displayName = "Python 3";
18 logo32 = "${env}/${env.sitePackages}/ipykernel/resources/logo-32x32.png";
19 logo64 = "${env}/${env.sitePackages}/ipykernel/resources/logo-64x64.png";
27 # Definitions is an attribute set.
29 create = { definitions ? default }: stdenv.mkDerivation {
31 name = "jupyter-kernels";
35 unpackCmd = "mkdir jupyter_kernels";
40 ${lib.concatStringsSep "\n" (lib.mapAttrsToList (kernelName: unfilteredKernel:
42 allowedKernelKeys = ["argv" "displayName" "language" "interruptMode" "env" "metadata" "logo32" "logo64" "extraPaths"];
43 kernel = lib.filterAttrs (n: v: (lib.any (x: x == n) allowedKernelKeys)) unfilteredKernel;
44 config = builtins.toJSON (
46 // {display_name = if (kernel.displayName != "") then kernel.displayName else kernelName;}
47 // (lib.optionalAttrs (kernel ? interruptMode) { interrupt_mode = kernel.interruptMode; })
49 extraPaths = kernel.extraPaths or {}
50 // lib.optionalAttrs (kernel.logo32 != null) { "logo-32x32.png" = kernel.logo32; }
51 // lib.optionalAttrs (kernel.logo64 != null) { "logo-64x64.png" = kernel.logo64; }
53 linkExtraPaths = lib.mapAttrsToList (name: value: "ln -s ${value} 'kernels/${kernelName}/${name}';") extraPaths;
55 mkdir 'kernels/${kernelName}';
56 echo '${config}' > 'kernels/${kernelName}/kernel.json';
57 ${lib.concatStringsSep "\n" linkExtraPaths}
65 description = "Wrapper to create jupyter notebook kernel definitions";
66 homepage = "https://jupyter.org/";
67 maintainers = with lib.maintainers; [ aborsu ];