From a625e46a2bb08c3e3487babedf38cdca1aac3447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 6 Jun 2024 13:53:06 +0200 Subject: [PATCH] postgresql: better typecheck database and user names --- clanModules/postgresql/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clanModules/postgresql/default.nix b/clanModules/postgresql/default.nix index a0b45e43..2d6be390 100644 --- a/clanModules/postgresql/default.nix +++ b/clanModules/postgresql/default.nix @@ -63,7 +63,7 @@ let }; createDatabase = db: '' - CREATE DATABASE '${db.name}' ${ + CREATE DATABASE ${db.name} ${ lib.concatStringsSep " " ( lib.mapAttrsToList (name: value: "${name} = '${value}'") db.create.options ) @@ -91,7 +91,7 @@ in { options = { name = lib.mkOption { - type = lib.types.str; + type = lib.types.strMatching "[a-zA-Z0-9_]+"; default = name; }; # set to false, in case the upstream module uses ensureDatabase option @@ -128,7 +128,7 @@ in { name, ... }: { options.name = lib.mkOption { - type = lib.types.str; + type = lib.types.strMatching "[a-zA-Z0-9_]+"; default = name; }; }