nixos/ncps: Add a new option for --cache-lock-backend

This commit is contained in:
Wael Nasreddine
2026-01-17 00:53:38 -08:00
parent c3deadcb06
commit 5ab49ddaa4
2 changed files with 22 additions and 0 deletions
@@ -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 = {
+2
View File
@@ -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=="
);