nixos/services.livebook: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-27 20:43:09 +02:00
parent df4401eac8
commit f65c35866a

View File

@ -1,6 +1,4 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.services.livebook; cfg = config.services.livebook;
in in
@ -10,12 +8,12 @@ in
# either has access to all the data or none at all), the decision # either has access to all the data or none at all), the decision
# was made to run this as a user service. If that changes in the # was made to run this as a user service. If that changes in the
# future, this can be changed to a system service. # future, this can be changed to a system service.
enableUserService = mkEnableOption "a user service for Livebook"; enableUserService = lib.mkEnableOption "a user service for Livebook";
package = mkPackageOption pkgs "livebook" { }; package = lib.mkPackageOption pkgs "livebook" { };
environment = mkOption { environment = lib.mkOption {
type = with types; attrsOf (nullOr (oneOf [ bool int str ])); type = with lib.types; attrsOf (nullOr (oneOf [ bool int str ]));
default = { }; default = { };
description = '' description = ''
Environment variables to set. Environment variables to set.
@ -37,15 +35,15 @@ in
variables specified in this option. variables specified in this option.
''; '';
example = literalExpression '' example = lib.literalExpression ''
{ {
LIVEBOOK_PORT = 8080; LIVEBOOK_PORT = 8080;
} }
''; '';
}; };
environmentFile = mkOption { environmentFile = lib.mkOption {
type = with types; nullOr types.path; type = with lib.types; nullOr lib.types.path;
default = null; default = null;
description = '' description = ''
Additional dnvironment file as defined in {manpage}`systemd.exec(5)`. Additional dnvironment file as defined in {manpage}`systemd.exec(5)`.
@ -72,17 +70,17 @@ in
example = "/var/lib/livebook.env"; example = "/var/lib/livebook.env";
}; };
extraPackages = mkOption { extraPackages = lib.mkOption {
type = with types; listOf package; type = with lib.types; listOf package;
default = [ ]; default = [ ];
description = '' description = ''
Extra packages to make available to the Livebook service. Extra packages to make available to the Livebook service.
''; '';
example = literalExpression "with pkgs; [ gcc gnumake ]"; example = lib.literalExpression "with pkgs; [ gcc gnumake ]";
}; };
}; };
config = mkIf cfg.enableUserService { config = lib.mkIf cfg.enableUserService {
systemd.user.services.livebook = { systemd.user.services.livebook = {
serviceConfig = { serviceConfig = {
Restart = "always"; Restart = "always";
@ -97,8 +95,8 @@ in
# stuck running a `cat /dev/urandom | tr | fold` pipeline. # stuck running a `cat /dev/urandom | tr | fold` pipeline.
IgnoreSIGPIPE = false; IgnoreSIGPIPE = false;
}; };
environment = mapAttrs (name: value: environment = lib.mapAttrs (name: value:
if isBool value then boolToString value else toString value) if lib.isBool value then lib.boolToString value else toString value)
cfg.environment; cfg.environment;
path = [ pkgs.bash ] ++ cfg.extraPackages; path = [ pkgs.bash ] ++ cfg.extraPackages;
wantedBy = [ "default.target" ]; wantedBy = [ "default.target" ];