Merge pull request #56335 from Izorkin/nginx-fix-config
nginx: fix formating the config file
This commit is contained in:
commit
0d3230f339
@ -44,7 +44,7 @@ let
|
|||||||
}
|
}
|
||||||
''));
|
''));
|
||||||
|
|
||||||
awkFormat = pkgs.writeText "awkFormat-nginx.awk" ''
|
awkFormat = builtins.toFile "awkFormat-nginx.awk" ''
|
||||||
awk -f
|
awk -f
|
||||||
{sub(/^[ \t]+/,"");idx=0}
|
{sub(/^[ \t]+/,"");idx=0}
|
||||||
/\{/{ctx++;idx=1}
|
/\{/{ctx++;idx=1}
|
||||||
@ -52,15 +52,9 @@ let
|
|||||||
{id="";for(i=idx;i<ctx;i++)id=sprintf("%s%s", id, "\t");printf "%s%s\n", id, $0}
|
{id="";for(i=idx;i<ctx;i++)id=sprintf("%s%s", id, "\t");printf "%s%s\n", id, $0}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
configFile = pkgs.stdenv.mkDerivation {
|
configFile = pkgs.runCommand "nginx.conf" {} (''
|
||||||
name = "nginx-config";
|
awk -f ${awkFormat} ${pre-configFile} | sed '/^\s*$/d' > $out
|
||||||
src = "";
|
'');
|
||||||
phases = [ "installPhase" ];
|
|
||||||
installPhase = ''
|
|
||||||
mkdir $out
|
|
||||||
awk -f ${awkFormat} ${pre-configFile} | sed '/^\s*$/d' > $out/nginx.conf
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
pre-configFile = pkgs.writeText "pre-nginx.conf" ''
|
pre-configFile = pkgs.writeText "pre-nginx.conf" ''
|
||||||
user ${cfg.user} ${cfg.group};
|
user ${cfg.user} ${cfg.group};
|
||||||
@ -656,10 +650,10 @@ in
|
|||||||
preStart =
|
preStart =
|
||||||
''
|
''
|
||||||
${cfg.preStart}
|
${cfg.preStart}
|
||||||
${cfg.package}/bin/nginx -c ${configFile}/nginx.conf -p ${cfg.stateDir} -t
|
${cfg.package}/bin/nginx -c ${configFile} -p ${cfg.stateDir} -t
|
||||||
'';
|
'';
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${cfg.package}/bin/nginx -c ${configFile}/nginx.conf -p ${cfg.stateDir}";
|
ExecStart = "${cfg.package}/bin/nginx -c ${configFile} -p ${cfg.stateDir}";
|
||||||
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
RestartSec = "10s";
|
RestartSec = "10s";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user