X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=modules%2Fprivate%2Fdatabases%2Fredis_replication.nix;h=53fa90407947d367ca2df52529b7dc7e6373f992;hb=05becbbb4be5cd18cb12d60a2d2bc0fbcda74fe4;hp=cc626f56b7d8db6cdb0275eaf1b2dadc0bfaa203;hpb=dded66995529a0419cc56778f4ebb4247c2ab765;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/modules/private/databases/redis_replication.nix b/modules/private/databases/redis_replication.nix index cc626f5..53fa904 100644 --- a/modules/private/databases/redis_replication.nix +++ b/modules/private/databases/redis_replication.nix @@ -1,4 +1,4 @@ -{ pkgs, config, myconfig, lib, ... }: +{ pkgs, config, lib, ... }: let cfg = config.myServices.databasesReplication.redis; in @@ -63,14 +63,13 @@ in config.redis = { encrypt = true; source = "127.0.0.1:16379"; - target = "${myconfig.env.servers.eldiron.ips.main.ip4}:16379"; - keyfile = "${config.secrets.location}/redis/spiped_eldiron_keyfile"; + target = "${lib.head config.myEnv.servers.eldiron.ips.main.ip4}:16379"; + keyfile = config.secrets.fullPaths."redis/spiped_eldiron_keyfile"; }; }; - secrets.keys = lib.flatten (lib.mapAttrsToList (name: hcfg: [ - { - dest = "redis_replication/${name}/config"; + secrets.keys = lib.mapAttrs' (name: hcfg: + lib.nameValuePair "redis_replication/${name}/config" { user = "redis"; group = "redis"; permissions = "0400"; @@ -97,15 +96,14 @@ in maxclients 1024 ''; } - ]) cfg.hosts) ++ [ - { # For eldiron only - dest = "redis/spiped_eldiron_keyfile"; + ) cfg.hosts // { + "redis/spiped_eldiron_keyfile" = { # For eldiron only user = "spiped"; group = "spiped"; permissions = "0400"; - text = myconfig.env.databases.redis.spiped_key; - } - ]; + text = config.myEnv.databases.redis.spiped_key; + }; + }; services.cron = { enable = true; @@ -117,7 +115,7 @@ in #!${pkgs.stdenv.shell} ${pkgs.coreutils}/bin/cp ${cfg.base}/${name}/redis/dump.rdb \ - ${backupDir}/$(${pkgs.coreutils}/bin/date -Iseconds).rdb + ${backupDir}/$(${pkgs.coreutils}/bin/date -Iminutes).rdb ''; u = pkgs.callPackage ./utils.nix {}; cleanup_script = pkgs.writeScript "cleanup_redis_${name}" (u.exponentialDumps "rdb" backupDir); @@ -162,7 +160,7 @@ in unitConfig.RequiresMountsFor = dataDir; serviceConfig = { - ExecStart = "${hcfg.package}/bin/redis-server ${config.secrets.location}/redis_replication/${name}/config"; + ExecStart = "${hcfg.package}/bin/redis-server ${config.secrets.fullPaths."redis_replication/${name}/config"}"; User = "redis"; RuntimeDirectory = "redis_${name}"; };