Merge pull request #57979 from 4z3/writeNginxConfig
nixos/nginx: use nginxfmt and gixy
This commit is contained in:
commit
6dd7483ce1
@ -44,19 +44,7 @@ let
|
||||
}
|
||||
''));
|
||||
|
||||
awkFormat = 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}
|
||||
'';
|
||||
|
||||
configFile = pkgs.runCommand "nginx.conf" {} (''
|
||||
awk -f ${awkFormat} ${pre-configFile} | sed '/^\s*$/d' > $out
|
||||
'');
|
||||
|
||||
pre-configFile = pkgs.writeText "pre-nginx.conf" ''
|
||||
configFile = pkgs.writers.writeNginxConfig "nginx.conf" ''
|
||||
user ${cfg.user} ${cfg.group};
|
||||
error_log ${cfg.logError};
|
||||
daemon off;
|
||||
|
@ -178,6 +178,16 @@ rec {
|
||||
writeJSBin = name:
|
||||
writeJS "/bin/${name}";
|
||||
|
||||
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
|
||||
${pkgs.gixy}/bin/gixy $out
|
||||
'';
|
||||
|
||||
# writePerl takes a name an attributeset with libraries and some perl sourcecode and
|
||||
# returns an executable
|
||||
#
|
||||
|
@ -1,14 +1,14 @@
|
||||
{ stdenv, fetchFromGitHub, python3 }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
version = "2016-06-16";
|
||||
version = "2019-02-13";
|
||||
name = "nginx-config-formatter-${version}";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "1connect";
|
||||
repo = "nginx-config-formatter";
|
||||
rev = "fe5c77d2a503644bebee2caaa8b222c201c0603d";
|
||||
sha256 = "0akpkbq5136k1i1z1ls6yksis35hbr70k8vd10laqwvr1jj41bga";
|
||||
rev = "4ea6bbc1bdeb1d28419548aeca90f323e64e0e05";
|
||||
sha256 = "0h6pj9i0wim9pzkafi92l1nhlnl2a530vnm7qqi3n2ra8iwfyw4f";
|
||||
};
|
||||
|
||||
buildInputs = [ python3 ];
|
||||
|
Loading…
Reference in New Issue
Block a user