3
0
Fork 0
forked from mirrors/nixpkgs

nixos/nginx: fix error in writeNginxConfig

This commit is contained in:
Izorkin 2019-04-08 16:44:23 +03:00
parent d190794b4a
commit 496a73d46d
2 changed files with 11 additions and 3 deletions

View file

@ -28,6 +28,7 @@ import ./make-test.nix ({ pkgs, ...} : {
services.nginx.virtualHosts."0.my.test" = {
extraConfig = ''
access_log syslog:server=unix:/dev/log,facility=user,tag=mytag,severity=info ceeformat;
location /favicon.ico { allow all; access_log off; log_not_found off; }
'';
};
};

View file

@ -178,13 +178,20 @@ rec {
writeJSBin = name:
writeJS "/bin/${name}";
awkFormatNginx = builtins.toFile "awkFormat-nginx.awk" ''
awk -f
{sub(/^[ \t]+/,"");idx=0}
/\{/{ctx++;idx=1}
/\}/{ctx--}
{id="";for(i=idx;i<ctx;i++)id=sprintf("%s%s", id, "\t");printf "%s%s\n", id, $0}
'';
writeNginxConfig = name: text: pkgs.runCommand name {
inherit text;
passAsFile = [ "text" ];
} /* sh */ ''
cp "$textPath" $out
${pkgs.nginx-config-formatter}/bin/nginxfmt $out
${pkgs.gnused}/bin/sed -i '/^$/d' $out
# nginx-config-formatter has an error - https://github.com/1connect/nginx-config-formatter/issues/16
${pkgs.gawk}/bin/awk -f ${awkFormatNginx} "$textPath" | ${pkgs.gnused}/bin/sed '/^\s*$/d' > $out
${pkgs.gixy}/bin/gixy $out
'';