Code Monkey home page Code Monkey logo

jupyter-nix's Introduction

Jupyter ❤️ Nix

This repository provides a Nix-based framework for the definition of declarative and reproducible Jupyter environments. These environments include JupyterLab - configurable with extensions - the classic notebook, and configurable Jupyter kernels.

Getting started

{
  inputs.flake-utils.url = "...";
  inputs.nixpkgs.url = "...";
  inputs.jupyter.url = "...";

  outputs = { self, nixpkgs, jupyter }:
    flake-utils.lib.eachDefaultSystem (system: let
       pkgs = import nixpkgs { inherit system; };

       # customize mkJupyterLab function via .override
       mkJupyterLab = jupyter.lib.mkJupyterLab.override {
          poertryLock = ./custom/poetry.lock;
          kernels = k: [];
          extensions = e: e ++ []
       };

       # create jupyter instance (
       jupyterInstance = mkJupyterLab {        
         inherit pkgs;

         # list confiured kernels
         kernels = [
           (jupyter.lib.mkPythonKernel {
             inherit pkgs;
             displayName = "My python kernel";
             directory = ./python-env/;
           });
         };

         # list extensions to enable for jupyter
         extensions = e: [
           e.jupy-ext
          ];
       };
    in
    { packages.default = jupyterInstance; })
}

Contributing

TODO

License

This project is licensed under the MIT License. See the LICENSE file for details.

jupyter-nix's People

Contributors

guaraqe avatar mmesch avatar garbas avatar dependabot[bot] avatar gtrunsec avatar etjean avatar djacu avatar github-actions[bot] avatar teto avatar kristoff3r avatar profpatsch avatar fusetim avatar dorranh avatar vaibhavsagar avatar saeedhk avatar kirelagin avatar junjihashimoto avatar evax avatar oxzi avatar nlewo avatar bjornfor avatar dougburke avatar jamesdbrock avatar rissson avatar stolyaroleh avatar rehno-lindeque avatar freuk avatar flip111 avatar

Stargazers

 avatar Gabriele Modena avatar

Watchers

Mathieu Boespflug avatar Chuck Grindel avatar Richard Bullington-McGuire avatar Mark Potter avatar Tom Westerhout avatar  avatar

jupyter-nix's Issues

jupyter-lab runtime path

#38 brings the jupyter-lab paths under nix's control by setting the config, data, and runtime paths to a place in the nix store. Specifically, setting the runtime path to an immutable location causes jupyter-lab to fail to start as it needs to write jupyter_cookie_secret, jpserver-<pid>.json, and jpserver-<pid>-open.html to the runtime directory. As these are ephemeral, it might be best and necessary to put these back in the default user directory. Unless, of course, there is a way to have a writable directory in the nix store.

$ ./result/bin/jupyter-lab
[I 2022-06-28 21:01:51.329 ServerApp] jupyterlab | extension was successfully linked.
[I 2022-06-28 21:01:51.335 ServerApp] Writing Jupyter server cookie secret to /nix/store/p6mjjls4iykvlb4incf08wy0rq579i4m-jupyter-dir/runtime/jupyter_cookie_secret
[E 2022-06-28 21:01:51.335 ServerApp] Failed to write cookie secret to /nix/store/p6mjjls4iykvlb4incf08wy0rq579i4m-jupyter-dir/runtime/jupyter_cookie_secret: [Errno 30] Read-only file system: '/nix/store/p6mjjls4iykvlb4incf08wy0rq579i4m-jupyter-dir/runtime/jupyter_cookie_secret'
[I 2022-06-28 21:01:51.345 LabApp] JupyterLab extension loaded from /nix/store/6sc285jv74aakjafwxgvcdx0yzsg9lhj-python3-3.10.4-env/lib/python3.10/site-packages/jupyterlab
[I 2022-06-28 21:01:51.346 LabApp] JupyterLab application directory is /nix/store/ywawa31mn9wma28h0dc84cf0b55zl5l4-python3.10-jupyterlab-3.4.3/share/jupyter/lab
[I 2022-06-28 21:01:51.348 ServerApp] jupyterlab | extension was successfully loaded.
[I 2022-06-28 21:01:51.349 ServerApp] Serving notebooks from local directory: /home/bakerdn/tweag/jupyter-nix
[I 2022-06-28 21:01:51.349 ServerApp] Jupyter Server 1.17.1 is running at:
[I 2022-06-28 21:01:51.349 ServerApp] http://localhost:8888/lab?token=aa2c3fddafa723ce466fce52d71e5412c5efa8d75970f5d1
[I 2022-06-28 21:01:51.349 ServerApp]  or http://127.0.0.1:8888/lab?token=aa2c3fddafa723ce466fce52d71e5412c5efa8d75970f5d1
[I 2022-06-28 21:01:51.349 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[E 2022-06-28 21:01:51.349 ServerApp] Failed to write server-info to /nix/store/p6mjjls4iykvlb4incf08wy0rq579i4m-jupyter-dir/runtime/jpserver-1778025.json: [Errno 30] Read-only file system: '/nix/store/p6mjjls4iykvlb4incf08wy0rq579i4m-jupyter-dir/runtime/jpserver-1778025.json'
Traceback (most recent call last):
  File "/nix/store/ywawa31mn9wma28h0dc84cf0b55zl5l4-python3.10-jupyterlab-3.4.3/bin/.jupyter-lab-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/6sc285jv74aakjafwxgvcdx0yzsg9lhj-python3-3.10.4-env/lib/python3.10/site-packages/jupyter_server/extension/application.py", line 594, in launch_instance
    serverapp.start()
  File "/nix/store/6sc285jv74aakjafwxgvcdx0yzsg9lhj-python3-3.10.4-env/lib/python3.10/site-packages/jupyter_server/serverapp.py", line 2814, in start
    self.start_app()
  File "/nix/store/6sc285jv74aakjafwxgvcdx0yzsg9lhj-python3-3.10.4-env/lib/python3.10/site-packages/jupyter_server/serverapp.py", line 2743, in start_app
    self.write_browser_open_files()
  File "/nix/store/6sc285jv74aakjafwxgvcdx0yzsg9lhj-python3-3.10.4-env/lib/python3.10/site-packages/jupyter_server/serverapp.py", line 2619, in write_browser_open_files
    self.write_browser_open_file()
  File "/nix/store/6sc285jv74aakjafwxgvcdx0yzsg9lhj-python3-3.10.4-env/lib/python3.10/site-packages/jupyter_server/serverapp.py", line 2642, in write_browser_open_file
    with open(self.browser_open_file, "w", encoding="utf-8") as f:
OSError: [Errno 30] Read-only file system: '/nix/store/p6mjjls4iykvlb4incf08wy0rq579i4m-jupyter-dir/runtime/jpserver-1778025-open.html'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.