livebook: configurable package and extraPackages

Also fix examples to not include a semicolon in the .env file.
This commit is contained in:
Alexandru Scvortov 2023-12-24 18:45:12 +00:00
parent 067338523e
commit 0ae9c34391
3 changed files with 26 additions and 4 deletions

View file

@ -18,7 +18,7 @@ which runs the server.
port = 20123;
# See note below about security
environmentFile = pkgs.writeText "livebook.env" ''
LIVEBOOK_PASSWORD = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
LIVEBOOK_PASSWORD = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
'';
};
}
@ -37,3 +37,14 @@ A better approach would be to put the password in some secure
user-readable location and set `environmentFile = /home/user/secure/livebook.env`.
:::
### 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`:
```
services.livebook.extraPackages = with pkgs; [ gcc gnumake ];
```

View file

@ -12,6 +12,8 @@ in
# future, this can be changed to a system service.
enableUserService = mkEnableOption "a user service for Livebook";
package = mkPackageOption pkgs "livebook" { };
environmentFile = mkOption {
type = types.path;
description = lib.mdDoc ''
@ -63,6 +65,15 @@ in
}
'';
};
extraPackages = mkOption {
type = with types; listOf package;
default = [ ];
description = lib.mdDoc ''
Extra packages to make available to the Livebook service.
'';
example = literalExpression "with pkgs; [ gcc gnumake ]";
};
};
config = mkIf cfg.enableUserService {
@ -79,9 +90,9 @@ in
sname = cfg.erlang_node_short_name;
} // cfg.options);
in
"${pkgs.livebook}/bin/livebook server ${args}";
"${cfg.package}/bin/livebook server ${args}";
};
path = [ pkgs.bash ];
path = [ pkgs.bash ] ++ cfg.extraPackages;
wantedBy = [ "default.target" ];
};
};

View file

@ -11,7 +11,7 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: {
enableUserService = true;
port = 20123;
environmentFile = pkgs.writeText "livebook.env" ''
LIVEBOOK_PASSWORD = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
LIVEBOOK_PASSWORD = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
'';
options = {
cookie = "chocolate chip";