From e39740cca30b398f6b05f37993ba322c55ddbc0c Mon Sep 17 00:00:00 2001 From: steve-chavez Date: Tue, 5 May 2026 17:32:17 -0500 Subject: [PATCH] nix: allow empty PGRST_DB_ANON_ROLE on postgrest-run So we can do `PGRST_DB_ANON_ROLE="" postgrest-run` since empty string has meaning. argbash conflates both unset and empty string so this requires a workaround. --- nix/tools/cabalTools.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nix/tools/cabalTools.nix b/nix/tools/cabalTools.nix index 9db63eb20..18b7dd774 100644 --- a/nix/tools/cabalTools.nix +++ b/nix/tools/cabalTools.nix @@ -51,7 +51,7 @@ let docs = "Run PostgREST after building it interactively with cabal-install"; args = [ - "ARG_USE_ENV([PGRST_DB_ANON_ROLE], [postgrest_test_anonymous], [PostgREST anonymous role])" + "ARG_USE_ENV([PGRST_DB_ANON_ROLE], [], [PostgREST anonymous role. (default: 'postgrest_test_anonymous')])" "ARG_USE_ENV([PGRST_DB_POOL], [1], [PostgREST pool size])" "ARG_USE_ENV([PGRST_DB_POOL_ACQUISITION_TIMEOUT], [1], [PostgREST pool timeout])" "ARG_USE_ENV([PGRST_JWT_SECRET], [reallyreallyreallyreallyverysafe], [PostgREST JWT secret])" @@ -62,6 +62,10 @@ let withEnv = postgrest.env; } '' + # when there's a default, argbash conflates empty string with unset, so we do this workaround to be able to do `PGRST_DB_ANON_ROLE="" ` for manual testing + if [[ ! ''${PGRST_DB_ANON_ROLE+x} ]]; then + PGRST_DB_ANON_ROLE="postgrest_test_anonymous" + fi export PGRST_DB_ANON_ROLE export PGRST_DB_POOL export PGRST_DB_POOL_ACQUISITION_TIMEOUT @@ -80,7 +84,7 @@ let docs = "Run a profiled build of postgREST. This will generate a postgrest.prof file that can be used to do optimization."; args = [ - "ARG_USE_ENV([PGRST_DB_ANON_ROLE], [postgrest_test_anonymous], [PostgREST anonymous role])" + "ARG_USE_ENV([PGRST_DB_ANON_ROLE], [], [PostgREST anonymous role. (default: 'postgrest_test_anonymous')])" "ARG_USE_ENV([PGRST_DB_POOL], [1], [PostgREST pool size])" "ARG_USE_ENV([PGRST_DB_POOL_ACQUISITION_TIMEOUT], [1], [PostgREST pool timeout])" "ARG_USE_ENV([PGRST_JWT_SECRET], [reallyreallyreallyreallyverysafe], [PostgREST JWT secret])" @@ -90,6 +94,10 @@ let withEnv = postgrest.env; } '' + # when there's a default, argbash conflates empty string with unset, so we do this workaround to be able to do `PGRST_DB_ANON_ROLE="" ` for manual testing + if [[ ! ''${PGRST_DB_ANON_ROLE+x} ]]; then + PGRST_DB_ANON_ROLE="postgrest_test_anonymous" + fi export PGRST_DB_ANON_ROLE export PGRST_DB_POOL export PGRST_DB_POOL_ACQUISITION_TIMEOUT