nixos/postgresql: check config file syntax at build time
This commit is contained in:
parent
e0759a4973
commit
1b7ca69ecc
@ -543,6 +543,14 @@ systemd.services.nginx.serviceConfig.ReadWritePaths = [ "/var/www" ];
|
|||||||
will have changed.
|
will have changed.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The syntax of the PostgreSQL configuration file is now checked at build
|
||||||
|
time. If your configuration includes a file inaccessible inside the build
|
||||||
|
sandbox, set <varname>services.postgresql.checkConfig</varname> to
|
||||||
|
<literal>false</literal>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
The rkt module has been removed, it was archived by upstream.
|
The rkt module has been removed, it was archived by upstream.
|
||||||
|
@ -18,7 +18,12 @@ let
|
|||||||
else toString value;
|
else toString value;
|
||||||
|
|
||||||
# The main PostgreSQL configuration file.
|
# The main PostgreSQL configuration file.
|
||||||
configFile = pkgs.writeText "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}") cfg.settings));
|
||||||
|
|
||||||
|
configFileCheck = pkgs.runCommand "postgresql-configfile-check" {} ''
|
||||||
|
${cfg.package}/bin/postgres -D${configFile} -C config_file >/dev/null
|
||||||
|
touch $out
|
||||||
|
'';
|
||||||
|
|
||||||
groupAccessAvailable = versionAtLeast postgresql.version "11.0";
|
groupAccessAvailable = versionAtLeast postgresql.version "11.0";
|
||||||
|
|
||||||
@ -53,6 +58,12 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
checkConfig = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "Check the syntax of the configuration file at compile time";
|
||||||
|
};
|
||||||
|
|
||||||
dataDir = mkOption {
|
dataDir = mkOption {
|
||||||
type = types.path;
|
type = types.path;
|
||||||
defaultText = "/var/lib/postgresql/\${config.services.postgresql.package.psqlSchema}";
|
defaultText = "/var/lib/postgresql/\${config.services.postgresql.package.psqlSchema}";
|
||||||
@ -309,6 +320,8 @@ in
|
|||||||
"/share/postgresql"
|
"/share/postgresql"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
system.extraDependencies = lib.optional (cfg.checkConfig && pkgs.stdenv.hostPlatform == pkgs.stdenv.buildPlatform) configFileCheck;
|
||||||
|
|
||||||
systemd.services.postgresql =
|
systemd.services.postgresql =
|
||||||
{ description = "PostgreSQL Server";
|
{ description = "PostgreSQL Server";
|
||||||
|
|
||||||
@ -332,7 +345,7 @@ in
|
|||||||
touch "${cfg.dataDir}/.first_startup"
|
touch "${cfg.dataDir}/.first_startup"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ln -sfn "${configFile}" "${cfg.dataDir}/postgresql.conf"
|
ln -sfn "${configFile}/postgresql.conf" "${cfg.dataDir}/postgresql.conf"
|
||||||
${optionalString (cfg.recoveryConfig != null) ''
|
${optionalString (cfg.recoveryConfig != null) ''
|
||||||
ln -sfn "${pkgs.writeText "recovery.conf" cfg.recoveryConfig}" \
|
ln -sfn "${pkgs.writeText "recovery.conf" cfg.recoveryConfig}" \
|
||||||
"${cfg.dataDir}/recovery.conf"
|
"${cfg.dataDir}/recovery.conf"
|
||||||
|
Loading…
Reference in New Issue
Block a user