Merge pull request #57979 from 4z3/writeNginxConfig

nixos/nginx: use nginxfmt and gixy
This commit is contained in:
Jörg Thalheim 2019-04-04 20:23:58 +01:00 committed by GitHub
commit 6dd7483ce1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 16 deletions

View File

@ -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;

View File

@ -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
#

View File

@ -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 ];