Merge pull request #56335 from Izorkin/nginx-fix-config

nginx: fix formating the config file
This commit is contained in:
Elis Hirwing 2019-02-25 10:59:37 +01:00 committed by GitHub
commit 0d3230f339
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -44,7 +44,7 @@ let
}
''));
awkFormat = pkgs.writeText "awkFormat-nginx.awk" ''
awkFormat = builtins.toFile "awkFormat-nginx.awk" ''
awk -f
{sub(/^[ \t]+/,"");idx=0}
/\{/{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}
'';
configFile = pkgs.stdenv.mkDerivation {
name = "nginx-config";
src = "";
phases = [ "installPhase" ];
installPhase = ''
mkdir $out
awk -f ${awkFormat} ${pre-configFile} | sed '/^\s*$/d' > $out/nginx.conf
'';
};
configFile = pkgs.runCommand "nginx.conf" {} (''
awk -f ${awkFormat} ${pre-configFile} | sed '/^\s*$/d' > $out
'');
pre-configFile = pkgs.writeText "pre-nginx.conf" ''
user ${cfg.user} ${cfg.group};
@ -656,10 +650,10 @@ in
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 = {
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";
Restart = "always";
RestartSec = "10s";