2023-10-24 16:53:12 +00:00
|
|
|
# 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.
|
|
|
|
|
2024-03-27 16:33:27 +00:00
|
|
|
```nix
|
2023-10-24 16:53:12 +00:00
|
|
|
{ ... }:
|
|
|
|
|
|
|
|
{
|
|
|
|
services.livebook = {
|
|
|
|
enableUserService = true;
|
2024-01-23 21:36:52 +00:00
|
|
|
environment = {
|
|
|
|
LIVEBOOK_PORT = 20123;
|
|
|
|
LIVEBOOK_PASSWORD = "mypassword";
|
|
|
|
};
|
2023-10-24 16:53:12 +00:00
|
|
|
# See note below about security
|
2024-01-23 21:36:52 +00:00
|
|
|
environmentFile = "/var/lib/livebook.env";
|
2023-10-24 16:53:12 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
::: {.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.
|
|
|
|
|
2024-01-23 21:36:52 +00:00
|
|
|
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`.
|
2023-10-24 16:53:12 +00:00
|
|
|
|
|
|
|
:::
|
2023-12-24 18:45:12 +00:00
|
|
|
|
2024-01-23 21:36:52 +00:00
|
|
|
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`.
|
|
|
|
|
2023-12-24 18:45:12 +00:00
|
|
|
### 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`:
|
|
|
|
|
2024-03-27 16:33:27 +00:00
|
|
|
```nix
|
2024-03-27 18:10:27 +00:00
|
|
|
{
|
|
|
|
services.livebook.extraPackages = with pkgs; [ gcc gnumake ];
|
|
|
|
}
|
2023-12-24 18:45:12 +00:00
|
|
|
```
|