nixpkgs/nixos/modules/services/development/livebook.md
Janne Heß fcc95ff817 treewide: Fix all Nix ASTs in all markdown files
This allows for correct highlighting and maybe future automatic
formatting. The AST was verified to work with nixfmt only.
2024-03-28 09:28:12 +01:00

1.7 KiB

Livebook

Livebook is a web application for writing interactive and collaborative code notebooks.

Basic Usage

Enabling the livebook service creates a user systemd unit which runs the server.

{ ... }:

{
  services.livebook = {
    enableUserService = true;
    environment = {
      LIVEBOOK_PORT = 20123;
      LIVEBOOK_PASSWORD = "mypassword";
    };
    # See note below about security
    environmentFile = "/var/lib/livebook.env";
  };
}

::: {.note}

The Livebook server has the ability to run any command as the user it is running under, so securing access to it with a password is highly recommended.

Putting the password in the Nix configuration like above is an easy way to get started but it is not recommended in the real world because the resulting environment variables can be read by unprivileged users. A better approach would be to put the password in some secure user-readable location and set environmentFile = /home/user/secure/livebook.env.

:::

The Livebook documentation lists all the applicable environment variables. It is recommended to at least set LIVEBOOK_PASSWORD or LIVEBOOK_TOKEN_ENABLED=false.

Extra dependencies

By default, the Livebook service is run with minimum dependencies, but some features require additional packages. For example, the machine learning Kinos require gcc and gnumake. To add these, use extraPackages:

{
  services.livebook.extraPackages = with pkgs; [ gcc gnumake ];
}