nixos/pgadmin: apply review suggestions

Signed-off-by: Florian Brandes <florian.brandes@posteo.de>
This commit is contained in:
Florian Brandes 2024-01-11 10:34:37 +01:00
parent 010a6250db
commit bc21d288f4
No known key found for this signature in database
GPG Key ID: 074048E893713170
2 changed files with 6 additions and 7 deletions

View File

@ -44,13 +44,13 @@ in
initialPasswordFile = mkOption { initialPasswordFile = mkOption {
description = lib.mdDoc '' description = lib.mdDoc ''
Initial password file for the pgAdmin account. Minimum length by default is 6. Initial password file for the pgAdmin account. Minimum length by default is 6.
Please see services.pgadmin.passwordLength. Please see `services.pgadmin.minimumPasswordLength`.
NOTE: Should be string not a store path, to prevent the password from being world readable NOTE: Should be string not a store path, to prevent the password from being world readable
''; '';
type = types.path; type = types.path;
}; };
passwordLength = mkOption { minimumPasswordLength = mkOption {
description = lib.mdDoc "Minimum length of the password"; description = lib.mdDoc "Minimum length of the password";
type = types.int; type = types.int;
default = 6; default = 6;
@ -122,7 +122,7 @@ in
services.pgadmin.settings = { services.pgadmin.settings = {
DEFAULT_SERVER_PORT = cfg.port; DEFAULT_SERVER_PORT = cfg.port;
PASSWORD_LENGTH_MIN = cfg.passwordLength; PASSWORD_LENGTH_MIN = cfg.minimumPasswordLength;
SERVER_MODE = true; SERVER_MODE = true;
} // (optionalAttrs cfg.openFirewall { } // (optionalAttrs cfg.openFirewall {
DEFAULT_SERVER = mkDefault "::"; DEFAULT_SERVER = mkDefault "::";
@ -151,9 +151,8 @@ in
# and presenting a hard to find error message # and presenting a hard to find error message
# see https://github.com/NixOS/nixpkgs/issues/270624 # see https://github.com/NixOS/nixpkgs/issues/270624
PW_LENGTH=$(wc -m < ${escapeShellArg cfg.initialPasswordFile}) PW_LENGTH=$(wc -m < ${escapeShellArg cfg.initialPasswordFile})
if [ $PW_LENGTH -lt ${toString cfg.passwordLength} ] if [ $PW_LENGTH -lt ${toString cfg.minimumPasswordLength} ]; then
then echo "Password must be at least ${toString cfg.minimumPasswordLength} characters long"
echo "Password must be at least ${toString cfg.passwordLength} characters long"
exit 1 exit 1
fi fi
( (

View File

@ -41,7 +41,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }:
enable = true; enable = true;
initialEmail = "bruh@localhost.de"; initialEmail = "bruh@localhost.de";
initialPasswordFile = pkgs.writeText "pw" "bruh2012!"; initialPasswordFile = pkgs.writeText "pw" "bruh2012!";
passwordLength = 12; minimumPasswordLength = 12;
}; };
}; };
}; };