Fediversity/deployment/options.nix
Kiara Grouwstra 9a25a04bfa specify _class module attributes to explicitly declare module types (#398)
closes #93.

note that this includes classes:

- `nixos`
- `nixosTest`
- `nixops4Resource`
- `nixops4Deployment`

.. and my (made-up, as per the [docs](https://ryantm.github.io/nixpkgs/module-system/module-system/#module-system-lib-evalModules-param-class)):

- `nix-unit`
- `package`

.. while i did not manage to cover:

- service tests, given `pkgs.nixosTest` seemed to not actually like `_class = "nixosTest"` (?!)

... nor #93's mentioned destructured arguments for that matter, as per Fediversity/Fediversity#93 (comment) - let me know if that is still desired as well.

Reviewed-on: Fediversity/Fediversity#398
Reviewed-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Co-authored-by: Kiara Grouwstra <kiara@procolix.eu>
Co-committed-by: Kiara Grouwstra <kiara@procolix.eu>
2025-06-23 17:24:54 +02:00

104 lines
2.7 KiB
Nix

/**
Deployment options as to be presented in the front end.
These are converted to JSON schema in order to generate front-end forms etc.
For this to work, options must not have types `functionTo` or `package`, and must not access `config` for their default values.
The options are written in a cumbersome way because the JSON schema converter can't evaluate a submodule option's default value, which thus all must be set to `null`.
This can be fixed if we made the converter aware of [`$defs`], but that would likely amount to half a rewrite.
[`$defs`]: https://json-schema.org/understanding-json-schema/structuring#defs
*/
{
lib,
...
}:
let
inherit (lib) types mkOption;
in
{
_class = "nixops4Deployment";
options = {
enable = lib.mkEnableOption "Fediversity configuration";
domain = mkOption {
type =
with types;
enum [
"fediversity.net"
];
description = ''
Apex domain under which the services will be deployed.
'';
default = "fediversity.net";
};
pixelfed = mkOption {
description = ''
Configuration for the Pixelfed service
'';
type =
with types;
nullOr (submodule {
options = {
enable = lib.mkEnableOption "Pixelfed";
};
});
default = null;
};
peertube = mkOption {
description = ''
Configuration for the PeerTube service
'';
type =
with types;
nullOr (submodule {
options = {
enable = lib.mkEnableOption "Peertube";
};
});
default = null;
};
mastodon = mkOption {
description = ''
Configuration for the Mastodon service
'';
type =
with types;
nullOr (submodule {
options = {
enable = lib.mkEnableOption "Mastodon";
};
});
default = null;
};
initialUser = mkOption {
description = ''
Some services require an initial user to access them.
This option sets the credentials for such an initial user.
'';
type =
with types;
nullOr (submodule {
options = {
displayName = mkOption {
type = types.str;
description = "Display name of the user";
};
username = mkOption {
type = types.str;
description = "Username for login";
};
email = mkOption {
type = types.str;
description = "User's email address";
};
password = mkOption {
type = types.str;
description = "Password for login";
};
};
});
default = null;
};
};
}