nixos/ncps: Add a new option for --cache-lock-backend
This commit is contained in:
@@ -51,6 +51,7 @@ let
|
||||
serveFlags = lib.concatStringsSep " " (
|
||||
[
|
||||
"--cache-hostname='${cfg.cache.hostName}'"
|
||||
"--cache-lock-backend='${cfg.cache.lock.backend}'"
|
||||
"--cache-temp-path='${cfg.cache.tempPath}'"
|
||||
"--server-addr='${cfg.server.addr}'"
|
||||
]
|
||||
@@ -232,6 +233,17 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
lock.backend = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"local"
|
||||
"redis"
|
||||
];
|
||||
default = "local";
|
||||
description = ''
|
||||
Lock backend to use: 'local' (single instance), 'redis' (distributed).
|
||||
'';
|
||||
};
|
||||
|
||||
maxSize = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
@@ -487,6 +499,14 @@ in
|
||||
cfg.cache.redis == null || cfg.cache.redis.password == null || cfg.cache.redis.passwordFile == null;
|
||||
message = "You cannot specify both config.ncps.cache.redis.password and config.ncps.cache.redis.passwordFile";
|
||||
}
|
||||
{
|
||||
assertion = cfg.cache.lock.backend == "redis" -> cfg.cache.redis != null;
|
||||
message = "You must specify config.ncps.cache.redis when config.ncps.cache.lock.backend is set to 'redis'";
|
||||
}
|
||||
{
|
||||
assertion = cfg.cache.redis != null -> cfg.cache.lock.backend == "redis";
|
||||
message = "You must set config.ncps.cache.lock.backend to 'redis' when config.ncps.cache.redis is set";
|
||||
}
|
||||
];
|
||||
|
||||
users.users.ncps = {
|
||||
|
||||
@@ -35,6 +35,8 @@ let
|
||||
|
||||
databaseURL = "postgres://ncps:${lib.escapeURL postgresPassword}@postgres:5432/ncps?sslmode=disable";
|
||||
|
||||
lock.backend = "redis";
|
||||
|
||||
secretKeyPath = builtins.toString (
|
||||
pkgs.writeText "ncps-cache-key" "ncps:dcrGsrku0KvltFhrR5lVIMqyloAdo0y8vYZOeIFUSLJS2IToL7dPHSSCk/fi+PJf8EorpBn8PU7MNhfvZoI8mA=="
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user