summaryrefslogtreecommitdiff
path: root/os/srv/redis.nix
blob: a51f9dbe59ef1597182cd76971d8fe74e98c1c99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{ config, lib, ... }:
let
  cfg = config.os.srv.redis;
in
{
  options.os.srv.redis.enable = lib.mkEnableOption "";
  config = lib.mkIf cfg.enable {
    assertions = [
      {
        assertion = config.os.srv.sops.enable;
        message = "Required for password secure password storing";
      }
      {
        assertion = config.os.core.network.enableFirewall;
        message = "Requires firewall";
      }
    ];

    sops.secrets."redis/password" = {
      owner = "redis-main";
      restartUnits = [ "redis-servers-main.service" ];
    };

    services.redis.servers."main" = {
      enable = true;
      bind = config.os.core.network.ips.database-vm;
      port = 6379;

      requirePassFile = config.sops.secrets."redis/password".path;
    };

    networking.firewall.extraInputRules = ''
      ip saddr 10.0.0.0/24 tcp dport 6379 accept
    '';

  };
}