git.iko.soy/typeable/nixpkgs
on master help sign in
redis service: add firewall and VM overcommit options

- Add vm.over_commit setting for background saving - Add openFirewall setting Closes #10193

commit3a1beb6347799a8d8f3290a6158b2d5249c7ecb8 authorBen Smith <polynomial@gmail.com> dateFri 2 Oct 2015, 23:22 (11 years ago) parent3e0943d
1 file changed+24
nixos/modules/services/databases/redis.nix+24
nixos/modules/services/databases/redis.nix+24
@@ -68,6 +68,22 @@ in
6868 description = "The port for Redis to listen to.";
6969 };
7070
71+ vmOverCommit = mkOption {
72+ type = types.bool;
73+ default = false;
74+ description = ''
75+ Set vm.overcommit_memory to 1 (Suggested for Background Saving: http://redis.io/topics/faq)
76+ '';
77+ };
78+
79+ openFirewall = mkOption {
80+ type = types.bool;
81+ default = false;
82+ description = ''
83+ Whether to open ports in the firewall for the server.
84+ '';
85+ };
86+
7187 bind = mkOption {
7288 type = with types; nullOr str;
7389 default = null; # All interfaces
@@ -193,6 +209,14 @@ in
193209
194210 config = mkIf config.services.redis.enable {
195211
212+ boot.kernel.sysctl = mkIf cfg.vmOverCommit {
213+ "vm.overcommit_memory" = "1";
214+ };
215+
216+ networking.firewall = mkIf cfg.openFirewall {
217+ allowedTCPPorts = [ cfg.port ];
218+ };
219+
196220 users.extraUsers.redis =
197221 { name = cfg.user;
198222 uid = config.ids.uids.redis;