2024-05-21 13:22:03 +00:00
|
|
|
# This is an example of a blank module.
|
2024-12-08 16:12:00 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
namespace,
|
|
|
|
...
|
|
|
|
}:
|
2024-05-21 13:22:03 +00:00
|
|
|
|
|
|
|
let
|
2024-12-06 18:04:47 +00:00
|
|
|
cfg = config.${namespace}.services.myModule;
|
2024-05-21 13:22:03 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
2024-12-06 18:04:47 +00:00
|
|
|
${namespace}.services.myModule = {
|
2024-09-08 15:58:56 +00:00
|
|
|
enable = lib.mkEnableOption "Enables this example module.";
|
2024-05-21 13:22:03 +00:00
|
|
|
attributes = lib.mkOption {
|
|
|
|
default = { };
|
|
|
|
type = lib.types.attrs;
|
|
|
|
description = "An example of an attributes option.";
|
|
|
|
};
|
|
|
|
string = lib.mkOption {
|
|
|
|
default = "";
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "An example of a string option.";
|
|
|
|
};
|
|
|
|
list = lib.mkOption {
|
|
|
|
default = [ ];
|
|
|
|
type = lib.types.listOf lib.types.int;
|
|
|
|
description = "An example of a list (of integers) option.";
|
|
|
|
};
|
2024-12-08 16:12:00 +00:00
|
|
|
enum = lib.mkOption {
|
2024-05-21 13:22:03 +00:00
|
|
|
default = "one";
|
2024-12-08 16:12:00 +00:00
|
|
|
type = lib.types.enum [
|
2024-05-21 13:22:03 +00:00
|
|
|
"one"
|
|
|
|
"two"
|
|
|
|
];
|
|
|
|
description = "An example of an enum option.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2024-05-22 20:47:55 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2024-12-08 16:12:00 +00:00
|
|
|
# Define the changes applied by this module here.
|
2024-05-21 13:22:03 +00:00
|
|
|
};
|
2024-09-07 17:44:14 +00:00
|
|
|
|
|
|
|
systemd.services = {
|
2024-12-08 16:12:00 +00:00
|
|
|
# Tell systemd to wait for the module's configuration directory to be available before starting the service.
|
2024-09-07 17:44:14 +00:00
|
|
|
myModule.unitConfig.RequiresMountsFor = cfg.home;
|
|
|
|
|
2024-12-08 16:12:00 +00:00
|
|
|
# Tell Nginx to wait for the service to be available before coming online.
|
2024-09-07 17:44:14 +00:00
|
|
|
nginx.wants = [ config.systemd.services.myModule.name ];
|
|
|
|
};
|
2024-05-21 13:22:03 +00:00
|
|
|
}
|