mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-11 15:27:20 +03:00
Merge pull request #59181 from Izorkin/nginx-format
nixos/nginx: fix error in writeNginxConfig
This commit is contained in:
commit
4d4f110ca5
@ -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 New Issue
Block a user