diff options
author | Azat Bahawi <azat@bahawi.net> | 2023-03-22 15:20:22 +0300 |
---|---|---|
committer | Azat Bahawi <azat@bahawi.net> | 2023-03-22 15:20:22 +0300 |
commit | eb6eebde166112397e8711a16a8618a52ecbcaca (patch) | |
tree | 8650b606bf9c5f48d843fb99e2212c052825d79a /modules/nixos/redis.nix | |
parent | 2023-03-21 (diff) |
2023-03-22
Diffstat (limited to 'modules/nixos/redis.nix')
-rw-r--r-- | modules/nixos/redis.nix | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/modules/nixos/redis.nix b/modules/nixos/redis.nix new file mode 100644 index 0000000..166407e --- /dev/null +++ b/modules/nixos/redis.nix @@ -0,0 +1,36 @@ +{ + config, + lib, + this, + ... +}: +with lib; let + cfg = config.nixfiles.modules.redis; +in { + options.nixfiles.modules.redis.enable = mkEnableOption "Redis"; + + config = mkIf cfg.enable { + services = { + redis = { + servers.default = { + enable = true; + bind = "127.0.0.1"; + port = 6379; + }; + vmOverCommit = true; + }; + + prometheus.exporters = { + redis = { + enable = true; + listenAddress = mkDefault this.wireguard.ipv4.address; + port = mkDefault 9121; + extraFlags = with config.services.redis.servers.default; [ + "--redis.addr=redis://${bind}:${toString port}" + "--redis.user=${user}" + ]; + }; + }; + }; + }; +} |