mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-18 19:51:17 +00:00
nixos/nginx: fix error in writeNginxConfig
This commit is contained in:
parent
d190794b4a
commit
496a73d46d
|
@ -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; }
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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
|
||||
'';
|
||||
|
||||
|
|
Loading…
Reference in a new issue