diff --git a/nixos/modules/services/development/jupyter/default.nix b/nixos/modules/services/development/jupyter/default.nix index 2e50e1dfa8d07..c1efd2f0a3445 100644 --- a/nixos/modules/services/development/jupyter/default.nix +++ b/nixos/modules/services/development/jupyter/default.nix @@ -17,7 +17,7 @@ let notebookConfig = pkgs.writeText "jupyter_config.py" '' ${cfg.notebookConfig} - c.NotebookApp.password = ${cfg.password} + ${if cfg.usePassword then "c.NotebookApp.password = ${cfg.password}" else ""} ''; in { @@ -37,7 +37,7 @@ in { # NOTE: We don't use top-level jupyter because we don't # want to pass in JUPYTER_PATH but use .environment instead, # saving a rebuild. - package = mkPackageOption pkgs [ "python3" "pkgs" "notebook" ] { }; + package = mkPackageOption pkgs [ "python3" "pkgs" "notebook" "jupyterlab" ] { }; command = mkOption { type = types.str; @@ -86,10 +86,19 @@ in { example = "users"; }; + usePassword = mkOption { + type = types.bool; + default = false; + description = '' + Whether to use a password for the notebook. + ''; + }; + password = mkOption { type = types.str; + default = "''"; description = '' - Password to use with notebook. + Password to use with the notebook. This option is only used if `usePassword` is set to true. Can be generated using: In [1]: from notebook.auth import passwd In [2]: passwd('test') diff --git a/pkgs/applications/editors/jupyter/kernel.nix b/pkgs/applications/editors/jupyter/kernel.nix index 3640de28e8acc..c7f1e59996d74 100644 --- a/pkgs/applications/editors/jupyter/kernel.nix +++ b/pkgs/applications/editors/jupyter/kernel.nix @@ -4,19 +4,26 @@ let default = { python3 = let - env = (python3.withPackages (ps: with ps; [ ipykernel ])); + env = python3.withPackages (pythonPackages: with pythonPackages; [ + # Provide standard data science tools by default + ipykernel + numpy + pandas + matplotlib + scikit-learn + ]); in { displayName = "Python 3"; argv = [ - env.interpreter + "${env.interpreter}" "-m" "ipykernel_launcher" "-f" "{connection_file}" ]; language = "python"; - logo32 = "${env}/${env.sitePackages}/ipykernel/resources/logo-32x32.png"; - logo64 = "${env}/${env.sitePackages}/ipykernel/resources/logo-64x64.png"; + logo32 = lib.mkIf (env.sitePackages != null) (builtins.toPath "/${env.sitePackages}/ipykernel/resources/logo-32x32.png"); + logo64 = lib.mkIf (env.sitePackages != null) (builtins.toPath "/${env.sitePackages}/ipykernel/resources/logo-64x64.png"); }; };