nix/modules/nixos/services/redis/default.nix

29 lines
836 B
Nix
Raw Normal View History

{ config, lib, ... }: {
options.snowflake.services.redis = {
enable = lib.mkEnableOption "Enable redis configuration";
servers = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule {
options = {
enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "whether to enable this particular redis server.";
};
port = lib.mkOption {
type = lib.types.port;
description = "port number to host this redis on.";
};
};
});
};
};
config = lib.mkIf config.snowflake.services.redis.enable {
services.redis.servers = lib.mapAttrs (redisname: redisCfg: {
enable = redisCfg.enable;
port = redisCfg.port;
}) config.snowflake.services.redis.servers;
};
}