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" = {
|
services.nginx.virtualHosts."0.my.test" = {
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
access_log syslog:server=unix:/dev/log,facility=user,tag=mytag,severity=info ceeformat;
|
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:
|
writeJSBin = name:
|
||||||
writeJS "/bin/${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 {
|
writeNginxConfig = name: text: pkgs.runCommand name {
|
||||||
inherit text;
|
inherit text;
|
||||||
passAsFile = [ "text" ];
|
passAsFile = [ "text" ];
|
||||||
} /* sh */ ''
|
} /* sh */ ''
|
||||||
cp "$textPath" $out
|
# nginx-config-formatter has an error - https://github.com/1connect/nginx-config-formatter/issues/16
|
||||||
${pkgs.nginx-config-formatter}/bin/nginxfmt $out
|
${pkgs.gawk}/bin/awk -f ${awkFormatNginx} "$textPath" | ${pkgs.gnused}/bin/sed '/^\s*$/d' > $out
|
||||||
${pkgs.gnused}/bin/sed -i '/^$/d' $out
|
|
||||||
${pkgs.gixy}/bin/gixy $out
|
${pkgs.gixy}/bin/gixy $out
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue