nixpkgs/pkgs/servers/web-apps/livebook/default.nix
Philip Munksgaard 897d5670a3
livebook: Use mix release to build instead of escript
The current build of livebook does not work with the new [Livebook
Teams](https://livebook.dev/teams/) features. The problem can be observed by
running the current version of livebook, adding a new team and going to the team
page. The process will crash and the team page will show a 500 error.

The base of the problem is that the escript build method is not officially
supported. This commit changes the livebook package to use the `mix release`
workflow, which is also the one used to build the official Docker container.

Unfortunately, the binary built with `mix release` does not support command line
arguments like the `escript` binary does. Instead, users need to pass in most of
the configuration as environment variables, as documented
[here](https://hexdocs.pm/livebook/readme.html#environment-variables). As a
result, this commit also changes the Livebook service to reflect this new way of
configuring Livebook.

Finally, the Livebook release configuration specifically excludes the
ERTS (Erlang Runtime System), which means that the resulting release cannot run
without Erlang installed.

I have tested the results (both of the package and the service) locally.
2024-01-26 20:19:46 +01:00

42 lines
1.1 KiB
Nix

{ lib, beamPackages, makeWrapper, rebar3, elixir, erlang, fetchFromGitHub, nixosTests }:
beamPackages.mixRelease rec {
pname = "livebook";
version = "0.12.1";
inherit elixir;
buildInputs = [ erlang ];
nativeBuildInputs = [ makeWrapper ];
src = fetchFromGitHub {
owner = "livebook-dev";
repo = "livebook";
rev = "v${version}";
hash = "sha256-Q4c0AelZZDPxE/rtoHIRQi3INMLHeiZ72TWgy183f4Q=";
};
mixFodDeps = beamPackages.fetchMixDeps {
pname = "mix-deps-${pname}";
inherit src version;
hash = "sha256-dyKhrbb7vazBV6LFERtGHLQXEx29vTgn074mY4fsHy4=";
};
postInstall = ''
wrapProgram $out/bin/livebook \
--prefix PATH : ${lib.makeBinPath [ elixir erlang ]} \
--set MIX_REBAR3 ${rebar3}/bin/rebar3
'';
passthru.tests = {
livebook-service = nixosTests.livebook-service;
};
meta = with lib; {
license = licenses.asl20;
homepage = "https://livebook.dev/";
description = "Automate code & data workflows with interactive Elixir notebooks";
maintainers = with maintainers; [ munksgaard ];
platforms = platforms.unix;
};
}