nixos/bacula: refactor option generation

The generation of the descriptions always used lib explicitly even
thoughit was already specified with 'with'.

Since using `with lib` is discouraged this was also changed to inherit.
This commit is contained in:
RaHoni 2023-12-22 14:34:33 +01:00
parent ad2f55dc4e
commit 2af073f716
No known key found for this signature in database
GPG key ID: 5962F3E9516FD551

View file

@ -4,9 +4,19 @@
# TODO: test configuration when building nixexpr (use -t parameter) # TODO: test configuration when building nixexpr (use -t parameter)
# TODO: support sqlite3 (it's deprecate?) and mysql # TODO: support sqlite3 (it's deprecate?) and mysql
with lib;
let let
inherit (lib)
concatStringsSep
literalExpression
mapAttrsToList
mdDoc
mkIf
mkOption
optional
optionalString
types
;
libDir = "/var/lib/bacula"; libDir = "/var/lib/bacula";
yes_no = bool: if bool then "yes" else "no"; yes_no = bool: if bool then "yes" else "no";
@ -220,7 +230,7 @@ let
password = mkOption { password = mkOption {
type = types.str; type = types.str;
# TODO: required? # TODO: required?
description = lib.mdDoc '' description = mdDoc ''
Specifies the password that must be supplied for the default Bacula Specifies the password that must be supplied for the default Bacula
Console to be authorized. The same password must appear in the Console to be authorized. The same password must appear in the
Director resource of the Console configuration file. For added Director resource of the Console configuration file. For added
@ -241,7 +251,7 @@ let
type = types.enum [ "no" "yes" ]; type = types.enum [ "no" "yes" ];
default = "no"; default = "no";
example = "yes"; example = "yes";
description = lib.mdDoc '' description = mdDoc ''
If Monitor is set to `no`, this director will have If Monitor is set to `no`, this director will have
full access to this Storage daemon. If Monitor is set to full access to this Storage daemon. If Monitor is set to
`yes`, this director will only be able to fetch the `yes`, this director will only be able to fetch the
@ -267,7 +277,7 @@ let
options = { options = {
changerDevice = mkOption { changerDevice = mkOption {
type = types.str; type = types.str;
description = lib.mdDoc '' description = mdDoc ''
The specified name-string must be the generic SCSI device name of the The specified name-string must be the generic SCSI device name of the
autochanger that corresponds to the normal read/write Archive Device autochanger that corresponds to the normal read/write Archive Device
specified in the Device resource. This generic SCSI device name specified in the Device resource. This generic SCSI device name
@ -286,7 +296,7 @@ let
changerCommand = mkOption { changerCommand = mkOption {
type = types.str; type = types.str;
description = lib.mdDoc '' description = mdDoc ''
The name-string specifies an external program to be called that will The name-string specifies an external program to be called that will
automatically change volumes as required by Bacula. Normally, this automatically change volumes as required by Bacula. Normally, this
directive will be specified only in the AutoChanger resource, which directive will be specified only in the AutoChanger resource, which
@ -308,14 +318,14 @@ let
}; };
devices = mkOption { devices = mkOption {
description = lib.mdDoc ""; description = mdDoc "";
type = types.listOf types.str; type = types.listOf types.str;
}; };
extraAutochangerConfig = mkOption { extraAutochangerConfig = mkOption {
default = ""; default = "";
type = types.lines; type = types.lines;
description = lib.mdDoc '' description = mdDoc ''
Extra configuration to be passed in Autochanger directive. Extra configuration to be passed in Autochanger directive.
''; '';
example = '' example = ''
@ -332,7 +342,7 @@ let
archiveDevice = mkOption { archiveDevice = mkOption {
# TODO: required? # TODO: required?
type = types.str; type = types.str;
description = lib.mdDoc '' description = mdDoc ''
The specified name-string gives the system file name of the storage The specified name-string gives the system file name of the storage
device managed by this storage daemon. This will usually be the device managed by this storage daemon. This will usually be the
device file name of a removable storage device (tape drive), for device file name of a removable storage device (tape drive), for
@ -349,7 +359,7 @@ let
mediaType = mkOption { mediaType = mkOption {
# TODO: required? # TODO: required?
type = types.str; type = types.str;
description = lib.mdDoc '' description = mdDoc ''
The specified name-string names the type of media supported by this The specified name-string names the type of media supported by this
device, for example, `DLT7000`. Media type names are device, for example, `DLT7000`. Media type names are
arbitrary in that you set them to anything you want, but they must be arbitrary in that you set them to anything you want, but they must be
@ -387,7 +397,7 @@ let
extraDeviceConfig = mkOption { extraDeviceConfig = mkOption {
default = ""; default = "";
type = types.lines; type = types.lines;
description = lib.mdDoc '' description = mdDoc ''
Extra configuration to be passed in Device directive. Extra configuration to be passed in Device directive.
''; '';
example = '' example = ''
@ -408,7 +418,7 @@ in {
enable = mkOption { enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = lib.mdDoc '' description = mdDoc ''
Whether to enable the Bacula File Daemon. Whether to enable the Bacula File Daemon.
''; '';
}; };
@ -417,7 +427,7 @@ in {
default = "${config.networking.hostName}-fd"; default = "${config.networking.hostName}-fd";
defaultText = literalExpression ''"''${config.networking.hostName}-fd"''; defaultText = literalExpression ''"''${config.networking.hostName}-fd"'';
type = types.str; type = types.str;
description = lib.mdDoc '' description = mdDoc ''
The client name that must be used by the Director when connecting. The client name that must be used by the Director when connecting.
Generally, it is a good idea to use a name related to the machine so Generally, it is a good idea to use a name related to the machine so
that error messages can be easily identified if you have multiple that error messages can be easily identified if you have multiple
@ -428,7 +438,7 @@ in {
port = mkOption { port = mkOption {
default = 9102; default = 9102;
type = types.port; type = types.port;
description = lib.mdDoc '' description = mdDoc ''
This specifies the port number on which the Client listens for This specifies the port number on which the Client listens for
Director connections. It must agree with the FDPort specified in Director connections. It must agree with the FDPort specified in
the Client resource of the Director's configuration file. the Client resource of the Director's configuration file.
@ -437,10 +447,10 @@ in {
director = mkOption { director = mkOption {
default = {}; default = {};
description = lib.mdDoc '' description = mdDoc ''
This option defines director resources in Bacula File Daemon. This option defines director resources in Bacula File Daemon.
''; '';
type = with types; attrsOf (submodule (directorOptions "services.bacula-fd")); type = types.attrsOf (types.submodule (directorOptions "services.bacula-fd"));
}; };
@ -456,7 +466,7 @@ in {
extraClientConfig = mkOption { extraClientConfig = mkOption {
default = ""; default = "";
type = types.lines; type = types.lines;
description = lib.mdDoc '' description = mdDoc ''
Extra configuration to be passed in Client directive. Extra configuration to be passed in Client directive.
''; '';
example = '' example = ''
@ -468,7 +478,7 @@ in {
extraMessagesConfig = mkOption { extraMessagesConfig = mkOption {
default = ""; default = "";
type = types.lines; type = types.lines;
description = lib.mdDoc '' description = mdDoc ''
Extra configuration to be passed in Messages directive. Extra configuration to be passed in Messages directive.
''; '';
example = '' example = ''
@ -481,7 +491,7 @@ in {
enable = mkOption { enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = lib.mdDoc '' description = mdDoc ''
Whether to enable Bacula Storage Daemon. Whether to enable Bacula Storage Daemon.
''; '';
}; };
@ -490,7 +500,7 @@ in {
default = "${config.networking.hostName}-sd"; default = "${config.networking.hostName}-sd";
defaultText = literalExpression ''"''${config.networking.hostName}-sd"''; defaultText = literalExpression ''"''${config.networking.hostName}-sd"'';
type = types.str; type = types.str;
description = lib.mdDoc '' description = mdDoc ''
Specifies the Name of the Storage daemon. Specifies the Name of the Storage daemon.
''; '';
}; };
@ -498,7 +508,7 @@ in {
port = mkOption { port = mkOption {
default = 9103; default = 9103;
type = types.port; type = types.port;
description = lib.mdDoc '' description = mdDoc ''
Specifies port number on which the Storage daemon listens for Specifies port number on which the Storage daemon listens for
Director connections. Director connections.
''; '';
@ -506,32 +516,32 @@ in {
director = mkOption { director = mkOption {
default = {}; default = {};
description = lib.mdDoc '' description = mdDoc ''
This option defines Director resources in Bacula Storage Daemon. This option defines Director resources in Bacula Storage Daemon.
''; '';
type = with types; attrsOf (submodule (directorOptions "services.bacula-sd")); type = types.attrsOf (types.submodule (directorOptions "services.bacula-sd"));
}; };
device = mkOption { device = mkOption {
default = {}; default = {};
description = lib.mdDoc '' description = mdDoc ''
This option defines Device resources in Bacula Storage Daemon. This option defines Device resources in Bacula Storage Daemon.
''; '';
type = with types; attrsOf (submodule deviceOptions); type = types.attrsOf (types.submodule deviceOptions);
}; };
autochanger = mkOption { autochanger = mkOption {
default = {}; default = {};
description = lib.mdDoc '' description = mdDoc ''
This option defines Autochanger resources in Bacula Storage Daemon. This option defines Autochanger resources in Bacula Storage Daemon.
''; '';
type = with types; attrsOf (submodule autochangerOptions); type = types.attrsOf (types.submodule autochangerOptions);
}; };
extraStorageConfig = mkOption { extraStorageConfig = mkOption {
default = ""; default = "";
type = types.lines; type = types.lines;
description = lib.mdDoc '' description = mdDoc ''
Extra configuration to be passed in Storage directive. Extra configuration to be passed in Storage directive.
''; '';
example = '' example = ''
@ -543,7 +553,7 @@ in {
extraMessagesConfig = mkOption { extraMessagesConfig = mkOption {
default = ""; default = "";
type = types.lines; type = types.lines;
description = lib.mdDoc '' description = mdDoc ''
Extra configuration to be passed in Messages directive. Extra configuration to be passed in Messages directive.
''; '';
example = '' example = ''
@ -565,7 +575,7 @@ in {
enable = mkOption { enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = lib.mdDoc '' description = mdDoc ''
Whether to enable Bacula Director Daemon. Whether to enable Bacula Director Daemon.
''; '';
}; };
@ -574,7 +584,7 @@ in {
default = "${config.networking.hostName}-dir"; default = "${config.networking.hostName}-dir";
defaultText = literalExpression ''"''${config.networking.hostName}-dir"''; defaultText = literalExpression ''"''${config.networking.hostName}-dir"'';
type = types.str; type = types.str;
description = lib.mdDoc '' description = mdDoc ''
The director name used by the system administrator. This directive is The director name used by the system administrator. This directive is
required. required.
''; '';
@ -583,7 +593,7 @@ in {
port = mkOption { port = mkOption {
default = 9101; default = 9101;
type = types.port; type = types.port;
description = lib.mdDoc '' description = mdDoc ''
Specify the port (a positive integer) on which the Director daemon Specify the port (a positive integer) on which the Director daemon
will listen for Bacula Console connections. This same port number will listen for Bacula Console connections. This same port number
must be specified in the Director resource of the Console must be specified in the Director resource of the Console
@ -596,7 +606,7 @@ in {
password = mkOption { password = mkOption {
# TODO: required? # TODO: required?
type = types.str; type = types.str;
description = lib.mdDoc '' description = mdDoc ''
Specifies the password that must be supplied for a Director. Specifies the password that must be supplied for a Director.
''; '';
}; };
@ -604,7 +614,7 @@ in {
extraMessagesConfig = mkOption { extraMessagesConfig = mkOption {
default = ""; default = "";
type = types.lines; type = types.lines;
description = lib.mdDoc '' description = mdDoc ''
Extra configuration to be passed in Messages directive. Extra configuration to be passed in Messages directive.
''; '';
example = '' example = ''
@ -615,7 +625,7 @@ in {
extraDirectorConfig = mkOption { extraDirectorConfig = mkOption {
default = ""; default = "";
type = types.lines; type = types.lines;
description = lib.mdDoc '' description = mdDoc ''
Extra configuration to be passed in Director directive. Extra configuration to be passed in Director directive.
''; '';
example = '' example = ''
@ -627,7 +637,7 @@ in {
extraConfig = mkOption { extraConfig = mkOption {
default = ""; default = "";
type = types.lines; type = types.lines;
description = lib.mdDoc '' description = mdDoc ''
Extra configuration for Bacula Director Daemon. Extra configuration for Bacula Director Daemon.
''; '';
example = '' example = ''