Home Explore Blog Models CI



nixpkgs

nixos/modules/services/development/livebook.md
0dd6110668aa4fcd16ee735a0128d73a1bb917e9b267459d00000003000006d9
# Livebook {#module-services-livebook}

[Livebook](https://livebook.dev/) is a web application for writing
interactive and collaborative code notebooks.

## Basic Usage {#module-services-livebook-basic-usage}

Enabling the `livebook` service creates a user
[`systemd`](https://www.freedesktop.org/wiki/Software/systemd/) unit
which runs the server.

```nix
{ ... }:

{
  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](https://hexdocs.pm/livebook/readme.html#environment-variables)
lists all the applicable environment variables. It is recommended to at least
set `LIVEBOOK_PASSWORD` or `LIVEBOOK_TOKEN_ENABLED=false`.

### Extra dependencies {#module-services-livebook-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`:

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

Chunks
0061445d (1st chunk of `nixos/modules/services/development/livebook.md`)
Title: Livebook Service Configuration
Summary
This document describes how to configure the Livebook web application as a service, specifically within a `systemd` unit. It details enabling the `livebook` service, setting environment variables like `LIVEBOOK_PORT` and `LIVEBOOK_PASSWORD`, and strongly recommends securing access with a password. It also advises against hardcoding sensitive information directly in Nix configurations due to security risks and suggests using an `environmentFile` instead. Additionally, it explains how to add extra dependencies, such as `gcc` and `gnumake` for certain Livebook features, using the `extraPackages` option.