From 58fd716d05e162ad620ea4ad339ee2ee23f85f42 Mon Sep 17 00:00:00 2001 From: Andrew Seward Date: Thu, 29 Oct 2020 23:35:50 -0700 Subject: [PATCH 1/2] Add extraConfig option to redis --- modules/services/redis/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/services/redis/default.nix b/modules/services/redis/default.nix index 860ebc1d..e7e8cc4c 100644 --- a/modules/services/redis/default.nix +++ b/modules/services/redis/default.nix @@ -52,6 +52,12 @@ in default = false; description = "By default data is only periodically persisted to disk, enable this option to use an append-only file for improved persistence."; }; + + services.redis.extraConfig = mkOption { + type = types.lines; + default = ""; + description = "Additional text to be appended to redis.conf."; + }; }; config = mkIf cfg.enable { @@ -69,6 +75,7 @@ in ${optionalString (cfg.unixSocket != null) "unixsocket ${cfg.unixSocket}"} dir ${cfg.dataDir} appendOnly ${if cfg.appendOnly then "yes" else "no"} + ${cfg.extraConfig} ''; }; From fe814c5e91620528c834a9c9eb8cbd99d364fec6 Mon Sep 17 00:00:00 2001 From: Andrew Seward Date: Mon, 2 Nov 2020 19:26:39 -0800 Subject: [PATCH 2/2] Add some test coverage for redis service --- release.nix | 1 + tests/services-redis.nix | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/services-redis.nix diff --git a/release.nix b/release.nix index 750510dc..2747eb64 100644 --- a/release.nix +++ b/release.nix @@ -121,6 +121,7 @@ let tests.services-ofborg = makeTest ./tests/services-ofborg.nix; tests.services-offlineimap = makeTest ./tests/services-offlineimap.nix; tests.services-privoxy = makeTest ./tests/services-privoxy.nix; + tests.services-redis = makeTest ./tests/services-redis.nix; tests.services-skhd = makeTest ./tests/services-skhd.nix; tests.services-spacebar = makeTest ./tests/services-spacebar.nix; tests.services-synapse-bt = makeTest ./tests/services-synapse-bt.nix; diff --git a/tests/services-redis.nix b/tests/services-redis.nix new file mode 100644 index 00000000..a46916b7 --- /dev/null +++ b/tests/services-redis.nix @@ -0,0 +1,26 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + redis = pkgs.runCommand "redis-0.0.0" {} "mkdir $out"; +in + +{ + services.redis.enable = true; + services.redis.package = redis; + services.redis.extraConfig = '' + maxmemory-policy allkeys-lru + stop-writes-on-bgsave-error no + ''; + + test = '' + echo >&2 "checking redis service in ~/Library/LaunchAgents" + grep "org.nixos.redis" ${config.out}/user/Library/LaunchAgents/org.nixos.redis.plist + grep "${redis}/bin/redis-server /etc/redis.conf" ${config.out}/user/Library/LaunchAgents/org.nixos.redis.plist + + echo >&2 "checking config in /etc/redis.conf" + grep "maxmemory-policy allkeys-lru" ${config.out}/etc/redis.conf + grep "stop-writes-on-bgsave-error no" ${config.out}/etc/redis.conf + ''; +}