Loading nixos/modules/services/databases/postgresql.md +3 −3 Original line number Diff line number Diff line Loading @@ -118,7 +118,7 @@ are already created. before = "service1.service"; after = "postgresql.service"; serviceConfig.User = "postgres"; environment.PSQL = "psql --port=${toString services.postgresql.port}"; environment.PSQL = "psql --port=${toString services.postgresql.settings.port}"; path = [ postgresql ]; script = '' $PSQL service1 -c 'GRANT SELECT ON ALL TABLES IN SCHEMA public TO "extraUser1"' Loading @@ -139,7 +139,7 @@ are already created. ```nix { environment.PSQL = "psql --port=${toString services.postgresql.port}"; environment.PSQL = "psql --port=${toString services.postgresql.settings.port}"; path = [ postgresql ]; systemd.services."service1".preStart = '' $PSQL -c 'GRANT SELECT ON ALL TABLES IN SCHEMA public TO "extraUser1"' Loading @@ -159,7 +159,7 @@ are already created. before = "service1.service"; after = "postgresql.service"; serviceConfig.User = "service1"; environment.PSQL = "psql --port=${toString services.postgresql.port}"; environment.PSQL = "psql --port=${toString services.postgresql.settings.port}"; path = [ postgresql ]; script = '' $PSQL -c 'GRANT SELECT ON ALL TABLES IN SCHEMA public TO "extraUser1"' Loading nixos/modules/services/databases/postgresql.nix +37 −24 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ let else toString value; # The main PostgreSQL configuration file. configFile = pkgs.writeTextDir "postgresql.conf" (concatStringsSep "\n" (mapAttrsToList (n: v: "${n} = ${toStr v}") cfg.settings)); configFile = pkgs.writeTextDir "postgresql.conf" (concatStringsSep "\n" (mapAttrsToList (n: v: "${n} = ${toStr v}") (filterAttrs (const (x: x != null)) cfg.settings))); configFileCheck = pkgs.runCommand "postgresql-configfile-check" {} '' ${cfg.package}/bin/postgres -D${configFile} -C config_file >/dev/null Loading @@ -41,6 +41,9 @@ in { imports = [ (mkRemovedOptionModule [ "services" "postgresql" "extraConfig" ] "Use services.postgresql.settings instead.") (mkRenamedOptionModule [ "services" "postgresql" "logLinePrefix" ] [ "services" "postgresql" "settings" "log_line_prefix" ]) (mkRenamedOptionModule [ "services" "postgresql" "port" ] [ "services" "postgresql" "settings" "port" ]) ]; ###### interface Loading @@ -57,14 +60,6 @@ in example = "postgresql_15"; }; port = mkOption { type = types.port; default = 5432; description = lib.mdDoc '' The port on which PostgreSQL listens. ''; }; checkConfig = mkOption { type = types.bool; default = true; Loading Loading @@ -352,7 +347,29 @@ in ''; }; logLinePrefix = mkOption { extraPlugins = mkOption { type = with types; coercedTo (listOf path) (path: _ignorePg: path) (functionTo (listOf path)); default = _: []; example = literalExpression "ps: with ps; [ postgis pg_repack ]"; description = lib.mdDoc '' List of PostgreSQL plugins. ''; }; settings = mkOption { type = with types; submodule { freeformType = attrsOf (oneOf [ bool float int str ]); options = { shared_preload_libraries = mkOption { type = nullOr (coercedTo (listOf str) (concatStringsSep ", ") str); default = null; example = literalExpression ''[ "auto_explain" "anon" ]''; description = mdDoc '' List of libraries to be preloaded. ''; }; log_line_prefix = mkOption { type = types.str; default = "[%p] "; example = "%m [%p] "; Loading @@ -363,17 +380,15 @@ in ''; }; extraPlugins = mkOption { type = with types; coercedTo (listOf path) (path: _ignorePg: path) (functionTo (listOf path)); default = _: []; example = literalExpression "ps: with ps; [ postgis pg_repack ]"; port = mkOption { type = types.port; default = 5432; description = lib.mdDoc '' List of PostgreSQL plugins. The port on which PostgreSQL listens. ''; }; settings = mkOption { type = with types; attrsOf (oneOf [ bool float int str ]); }; }; default = {}; description = lib.mdDoc '' PostgreSQL configuration. Refer to Loading Loading @@ -439,9 +454,7 @@ in hba_file = "${pkgs.writeText "pg_hba.conf" cfg.authentication}"; ident_file = "${pkgs.writeText "pg_ident.conf" cfg.identMap}"; log_destination = "stderr"; log_line_prefix = cfg.logLinePrefix; listen_addresses = if cfg.enableTCPIP then "*" else "localhost"; port = cfg.port; jit = mkDefault (if cfg.enableJIT then "on" else "off"); }; Loading Loading @@ -524,7 +537,7 @@ in # Wait for PostgreSQL to be ready to accept connections. postStart = '' PSQL="psql --port=${toString cfg.port}" PSQL="psql --port=${toString cfg.settings.port}" while ! $PSQL -d postgres -c "" 2> /dev/null; do if ! kill -0 "$MAINPID"; then exit 1; fi Loading nixos/modules/services/misc/forgejo.nix +2 −2 Original line number Diff line number Diff line Loading @@ -114,11 +114,11 @@ in port = mkOption { type = types.port; default = if !usePostgresql then 3306 else pg.port; default = if usePostgresql then pg.settings.port else 3306; defaultText = literalExpression '' if config.${opt.database.type} != "postgresql" then 3306 else config.${options.services.postgresql.port} else 5432 ''; description = mdDoc "Database host port."; }; Loading nixos/modules/services/misc/gitea.nix +2 −2 Original line number Diff line number Diff line Loading @@ -100,11 +100,11 @@ in port = mkOption { type = types.port; default = if !usePostgresql then 3306 else pg.port; default = if usePostgresql then pg.settings.port else 3306; defaultText = literalExpression '' if config.${opt.database.type} != "postgresql" then 3306 else config.${options.services.postgresql.port} else 5432 ''; description = lib.mdDoc "Database host port."; }; Loading nixos/modules/services/monitoring/zabbix-proxy.nix +2 −2 Original line number Diff line number Diff line Loading @@ -103,11 +103,11 @@ in port = mkOption { type = types.port; default = if cfg.database.type == "mysql" then mysql.port else pgsql.port; default = if cfg.database.type == "mysql" then mysql.port else pgsql.services.port; defaultText = literalExpression '' if config.${opt.database.type} == "mysql" then config.${options.services.mysql.port} else config.${options.services.postgresql.port} else config.services.postgresql.settings.port ''; description = lib.mdDoc "Database host port."; }; Loading Loading
nixos/modules/services/databases/postgresql.md +3 −3 Original line number Diff line number Diff line Loading @@ -118,7 +118,7 @@ are already created. before = "service1.service"; after = "postgresql.service"; serviceConfig.User = "postgres"; environment.PSQL = "psql --port=${toString services.postgresql.port}"; environment.PSQL = "psql --port=${toString services.postgresql.settings.port}"; path = [ postgresql ]; script = '' $PSQL service1 -c 'GRANT SELECT ON ALL TABLES IN SCHEMA public TO "extraUser1"' Loading @@ -139,7 +139,7 @@ are already created. ```nix { environment.PSQL = "psql --port=${toString services.postgresql.port}"; environment.PSQL = "psql --port=${toString services.postgresql.settings.port}"; path = [ postgresql ]; systemd.services."service1".preStart = '' $PSQL -c 'GRANT SELECT ON ALL TABLES IN SCHEMA public TO "extraUser1"' Loading @@ -159,7 +159,7 @@ are already created. before = "service1.service"; after = "postgresql.service"; serviceConfig.User = "service1"; environment.PSQL = "psql --port=${toString services.postgresql.port}"; environment.PSQL = "psql --port=${toString services.postgresql.settings.port}"; path = [ postgresql ]; script = '' $PSQL -c 'GRANT SELECT ON ALL TABLES IN SCHEMA public TO "extraUser1"' Loading
nixos/modules/services/databases/postgresql.nix +37 −24 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ let else toString value; # The main PostgreSQL configuration file. configFile = pkgs.writeTextDir "postgresql.conf" (concatStringsSep "\n" (mapAttrsToList (n: v: "${n} = ${toStr v}") cfg.settings)); configFile = pkgs.writeTextDir "postgresql.conf" (concatStringsSep "\n" (mapAttrsToList (n: v: "${n} = ${toStr v}") (filterAttrs (const (x: x != null)) cfg.settings))); configFileCheck = pkgs.runCommand "postgresql-configfile-check" {} '' ${cfg.package}/bin/postgres -D${configFile} -C config_file >/dev/null Loading @@ -41,6 +41,9 @@ in { imports = [ (mkRemovedOptionModule [ "services" "postgresql" "extraConfig" ] "Use services.postgresql.settings instead.") (mkRenamedOptionModule [ "services" "postgresql" "logLinePrefix" ] [ "services" "postgresql" "settings" "log_line_prefix" ]) (mkRenamedOptionModule [ "services" "postgresql" "port" ] [ "services" "postgresql" "settings" "port" ]) ]; ###### interface Loading @@ -57,14 +60,6 @@ in example = "postgresql_15"; }; port = mkOption { type = types.port; default = 5432; description = lib.mdDoc '' The port on which PostgreSQL listens. ''; }; checkConfig = mkOption { type = types.bool; default = true; Loading Loading @@ -352,7 +347,29 @@ in ''; }; logLinePrefix = mkOption { extraPlugins = mkOption { type = with types; coercedTo (listOf path) (path: _ignorePg: path) (functionTo (listOf path)); default = _: []; example = literalExpression "ps: with ps; [ postgis pg_repack ]"; description = lib.mdDoc '' List of PostgreSQL plugins. ''; }; settings = mkOption { type = with types; submodule { freeformType = attrsOf (oneOf [ bool float int str ]); options = { shared_preload_libraries = mkOption { type = nullOr (coercedTo (listOf str) (concatStringsSep ", ") str); default = null; example = literalExpression ''[ "auto_explain" "anon" ]''; description = mdDoc '' List of libraries to be preloaded. ''; }; log_line_prefix = mkOption { type = types.str; default = "[%p] "; example = "%m [%p] "; Loading @@ -363,17 +380,15 @@ in ''; }; extraPlugins = mkOption { type = with types; coercedTo (listOf path) (path: _ignorePg: path) (functionTo (listOf path)); default = _: []; example = literalExpression "ps: with ps; [ postgis pg_repack ]"; port = mkOption { type = types.port; default = 5432; description = lib.mdDoc '' List of PostgreSQL plugins. The port on which PostgreSQL listens. ''; }; settings = mkOption { type = with types; attrsOf (oneOf [ bool float int str ]); }; }; default = {}; description = lib.mdDoc '' PostgreSQL configuration. Refer to Loading Loading @@ -439,9 +454,7 @@ in hba_file = "${pkgs.writeText "pg_hba.conf" cfg.authentication}"; ident_file = "${pkgs.writeText "pg_ident.conf" cfg.identMap}"; log_destination = "stderr"; log_line_prefix = cfg.logLinePrefix; listen_addresses = if cfg.enableTCPIP then "*" else "localhost"; port = cfg.port; jit = mkDefault (if cfg.enableJIT then "on" else "off"); }; Loading Loading @@ -524,7 +537,7 @@ in # Wait for PostgreSQL to be ready to accept connections. postStart = '' PSQL="psql --port=${toString cfg.port}" PSQL="psql --port=${toString cfg.settings.port}" while ! $PSQL -d postgres -c "" 2> /dev/null; do if ! kill -0 "$MAINPID"; then exit 1; fi Loading
nixos/modules/services/misc/forgejo.nix +2 −2 Original line number Diff line number Diff line Loading @@ -114,11 +114,11 @@ in port = mkOption { type = types.port; default = if !usePostgresql then 3306 else pg.port; default = if usePostgresql then pg.settings.port else 3306; defaultText = literalExpression '' if config.${opt.database.type} != "postgresql" then 3306 else config.${options.services.postgresql.port} else 5432 ''; description = mdDoc "Database host port."; }; Loading
nixos/modules/services/misc/gitea.nix +2 −2 Original line number Diff line number Diff line Loading @@ -100,11 +100,11 @@ in port = mkOption { type = types.port; default = if !usePostgresql then 3306 else pg.port; default = if usePostgresql then pg.settings.port else 3306; defaultText = literalExpression '' if config.${opt.database.type} != "postgresql" then 3306 else config.${options.services.postgresql.port} else 5432 ''; description = lib.mdDoc "Database host port."; }; Loading
nixos/modules/services/monitoring/zabbix-proxy.nix +2 −2 Original line number Diff line number Diff line Loading @@ -103,11 +103,11 @@ in port = mkOption { type = types.port; default = if cfg.database.type == "mysql" then mysql.port else pgsql.port; default = if cfg.database.type == "mysql" then mysql.port else pgsql.services.port; defaultText = literalExpression '' if config.${opt.database.type} == "mysql" then config.${options.services.mysql.port} else config.${options.services.postgresql.port} else config.services.postgresql.settings.port ''; description = lib.mdDoc "Database host port."; }; Loading