From 7437268cd4962cb003198211063cfcda2703e01a Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 20 Mar 2019 18:46:43 +0100 Subject: [PATCH 1/2] build-support writers: add writeNginxConfig --- pkgs/build-support/writers/default.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkgs/build-support/writers/default.nix b/pkgs/build-support/writers/default.nix index 6e932ce860f6..3454450c1f3a 100644 --- a/pkgs/build-support/writers/default.nix +++ b/pkgs/build-support/writers/default.nix @@ -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 # From 59fac1a6d7e1983a1e7bd518129ff9ef39a013dd Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 20 Mar 2019 18:49:40 +0100 Subject: [PATCH 2/2] nixos/nginx: use writeNginxConfig --- .../modules/services/web-servers/nginx/default.nix | 14 +------------- pkgs/tools/misc/nginx-config-formatter/default.nix | 6 +++--- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix index 1c9fbe048f84..e577e8a50126 100644 --- a/nixos/modules/services/web-servers/nginx/default.nix +++ b/nixos/modules/services/web-servers/nginx/default.nix @@ -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 $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; diff --git a/pkgs/tools/misc/nginx-config-formatter/default.nix b/pkgs/tools/misc/nginx-config-formatter/default.nix index 37218f848684..e19eac1c51e5 100644 --- a/pkgs/tools/misc/nginx-config-formatter/default.nix +++ b/pkgs/tools/misc/nginx-config-formatter/default.nix @@ -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 ];